Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mode:generate) add enum support #704

Merged
merged 2 commits into from
Oct 25, 2018

Conversation

mkly
Copy link
Contributor

@mkly mkly commented Oct 22, 2018

Add support for model:generate --name User role:enum:{Admin, Guest}

Closes #550

@mkly
Copy link
Contributor Author

mkly commented Oct 22, 2018

Hello!
Thanks for this great tool. I was curious about enum support and discovered that I was not the only one. I took a first pass at it here. I imagine there is somewhere I should also be adding docs for this, so definitely let me know and I'll add them on to this PR. Let me know what I might need to adjust. 🎃

Best,
Mike

Add support for `model:generate --name User role:enum:{Admin, Guest}`

Closes sequelize#550
@sushantdhiman
Copy link
Contributor

Looks good, you can add an example here https://github.com/sequelize/cli/blob/master/docs/FAQ.md#how-can-i-generate-a-model

@mkly
Copy link
Contributor Author

mkly commented Oct 24, 2018

@sushantdhiman I updated the FAQ with the additional enum. Thanks for pointing me in the right direction.

@sushantdhiman sushantdhiman merged commit ee4e9db into sequelize:master Oct 25, 2018
@achacttn
Copy link

Am I crazy or does this cli syntax NOT work at all?

This is what I type into my terminal:

sequelize model:create --name Customer --attributes id:integer,nameTitle:enum:{Mr,Mrs,Miss,Ms,Dr,Prof},nameFirst:string,nameMiddle:string,nameLast:string

Result:

ERROR: Attribute 'nameTitle:enum:Mr' cannot be parsed: Unknown type 'Mr'

@mkly
Copy link
Contributor Author

mkly commented Dec 11, 2018

Hi @achacttn
I have a hunch your shell is modifying it. Try:

sequelize model:create --name Customer --attributes 'id:integer,nameTitle:enum:{Mr,Mrs,Miss,Ms,Dr,Prof},nameFirst:string,nameMiddle:string,nameLast:string'

or...

sequelize model:create --name Customer --attributes id:integer,nameTitle:enum:\{Mr,Mrs,Miss,Ms,Dr,Prof\},nameFirst:string,nameMiddle:string,nameLast:string

Unfortunately, that's probably going to confuse a fair amount of people. I'll post an update to the documentation. Thank you for letting me know.

@botaniQQQ
Copy link

botaniQQQ commented Feb 19, 2019

Hello, @mkly

sequelize model:create --name Customer --attributes nameTitle:enum:\{Mr,Mrs,Miss,Ms,Dr,Prof\}

Sequelize CLI [Node: 10.15.0, CLI: 5.3.0, ORM: 5.0.0-beta.16]

ERROR: Attribute 'nameTitle:enum:\{Mr,Mrs,Miss,Ms,Dr,Prof\}'
cannot be parsed: Unknown type '\{Mr,Mrs,Miss,Ms,Dr,Prof\}'

codetriage-readme-bot pushed a commit to codetriage-readme-bot/cli that referenced this pull request Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants