January 2019
Intermediate to advanced
460 pages
10h 33m
English
Let's start by creating the Chat model and migration. A chat itself does not store any data; we use it for grouping specific users' messages:
sequelize model:generate --models-path src/server/models --migrations-path src/server/migrations --name Chat --attributes firstName:string,lastName:string,email:string
Generate the migration for our association table, as follows:
sequelize migration:create --migrations-path src/server/migrations --name create-user-chats
Adjust the users_chats migration generated by the Sequelize CLI. We specify the user and chat IDs as attributes for our relationship. References inside of a migration automatically create foreign key constraints for us. The migration file should look like the following code ...
Read now
Unlock full access