【问题标题】:Unknown arguments Error while creating table in Sequelize command line在 Sequelize 命令行中创建表时出现未知参数错误
【发布时间】:2022-08-19 02:04:29
【问题描述】:

在尝试通过命令行使用 sequelize 创建项目表时,出现以下错误 -

sequelize model:create --name Item --attributes \'itemid:string  itemname:string  genericname:string  itemtype:string  batchno:string mfname:string  mfplant:string\'

Sequelize CLI [Node: 16.15.0, CLI: 6.4.1, ORM: 6.20.1]

Options:
  --version          Show version number                                                                       [boolean]
  --help             Show help                                                                                 [boolean]
  --env              The environment to run the command in                             [string] [default: \"development\"]
  --config           The path to the config file                                                                [string]
  --options-path     The path to a JSON file with additional options                                            [string]
  --migrations-path  The path to the migrations folder                                  [string] [default: \"migrations\"]
  --seeders-path     The path to the seeders folder                                        [string] [default: \"seeders\"]
  --models-path      The path to the models folder                                          [string] [default: \"models\"]
  --url              The database connection string to use. Alternative to using --config files                 [string]
  --debug            When available show various debug information                            [boolean] [default: false]
  --name             Defines the name of the new model                                               [string] [required]
  --attributes       A list of attributes                                                            [string] [required]
  --force            Forcefully re-creates model with the same name                                             [string]
  --underscored      Use snake case for the timestamp\'s attribute names                       [boolean] [default: false]

Unknown arguments: itemname:string, genericname:string, itemtype:string, batchno:string, mfname:string, mfplant:string\' 

我以类似的方式创建了一个用户表,它运行良好。

sequelize model:create --name PTUser --attributes \'userid:string,username:string,password:string,role:string,isadmin:boolean,address:string,insertdate:date,updatedate:date\'

我不确定哪里出了问题。

请帮忙。

提前致谢。

    标签: node.js command-line create-table sequelize-cli


    【解决方案1】:

    您不需要 ' 围绕属性:

    尝试这个:

    sequelize model:create --name PTUser --attributes userid:string,username:string,password:string,role:string,isadmin:boolean,address:string,insertdate:date,updatedate:date
    

    【讨论】:

      猜你喜欢
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-11
      • 1970-01-01
      • 2020-06-10
      相关资源
      最近更新 更多