Reputation: 97
Trying to create a model that has an enum field with certain values using Sequelize CLI.
sequelize model:generate --name user --attributes name:string,login_method:enum('email','google')
Error: bash: syntax error near unexpected token `('
What is the right syntax to do so?
Upvotes: 4
Views: 4114
Reputation: 1
npx sequelize-cli model:generate --name User --attributes username:string,email:string,password:string,role:ENUM("users","admin")
instead or writing this try this
npx sequelize-cli model:generate --name User --attributes username:string,email:string,password:string,role:enum:'{users,admin}'
Upvotes: 0
Reputation: 21
you can do it with
model:generate --name User --attributes 'login_method:enum:{google,facebook}'
Another good example is:
npx sequelize-cli model:generate --name devicelogs --attributes 'type:enum:{embedded,console,wearable,smarttv,browser,tablet,mobile}','browser:enum:{Chrome,Firefox,Safari,Opera,Internet Explorer,Edge,Edge Chromium,Yandex,Chromium,Mobile Safari,Samsung Browser}'
from sequelize-cli code you can also try
Upvotes: 2
Reputation: 61
https://github.com/sequelize/cli/blob/master/docs/FAQ.md
try
npx sequelize-cli model:generate --name user --attributes name:string,login_method:enum:'{email,google}'
Upvotes: 6
Reputation: 147
Try this one:
npx sequelize model:create --name User --attributes 'opts:enum:{x,y,z}'
Or
sequelize model:create --name User --attributes 'opts:enum:{x,y,z}'
Hope this will help you.
Upvotes: 0
Reputation: 2227
It should be possible to create enum values from model:create command
you can do like this .
$ sequelize model:create --name User --attributes opts:enum(x,y,z)
hope this help .
Upvotes: 0