tldr/pages/common/sequelize.md

25 lines
617 B
Markdown
Raw Normal View History

2020-02-17 12:36:56 +00:00
# sequelize
> Promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.
> More information: <https://sequelize.org/>.
- Create a model with 3 fields and a migration file:
2020-02-17 12:36:56 +00:00
`sequelize model:generate --name {{table_name}} --attributes {{field1:integer,field2:string,field3:boolean}}`
2020-02-17 12:36:56 +00:00
- Run the migration file:
`sequelize db:migrate`
- Revert all migrations:
`sequelize db:migrate:undo:all`
- Create a seed file with the specified name to populate the database:
`sequelize seed:generate --name {{seed_filename}}`
- Populate database using all seed files:
`sequelize db:seed:all`