You'll be creating a database with a theme of your choosing. You must have the following:
- At least 3 models
- Table names must be lowercased and snake_cased
- CRUD queries for each model
- C reate
- R ead
- U pdate
- D elete
You can hard code in information for the create, update, and delete. You can either create 3 separate files or one file for all of these queries.
These commands should be done in order. Remember, if you are a Windows user, these commands will be different obviously.
npm init
npm install sequelize pg
sequelize init
Modify your config.json
so that you're creating a database with your chosen name and modify the dialect to postgres
.
Create your database:
sequelize db:create
To create a new model, run:
sequelize model:generate --name <Your Model Name Goes Here> --attributes <someattribute>:<somedatatype>,<other stuff...>
Remember, there can be no spaces in between each attribute.
Once your model is created, don't forget to add the tableName
field in the model and adjust the migration generated accordingly.
After each model creation, run:
sequelize db:migrate
You can generate a seed file using:
sequelize seed:generate --name <Seed Name>
Run your seed using:
sequelize db:seed:all
Hint: You can also use falso:
npm i @ngneat/falso
Don't forget to require your models in the file you're using for your queries:
const {} = require('./models')
You can always revert a migration using:
sequelize db:migrate:undo
Submit your pull request utilizing the PR Guidelines.