You have created a brand new social media network called Social Sequelize. The front end of the application has been created, but we have no way of saving user data so that their information can persist when they come to the page.
GOAL: Construct a database that does the following:
- Connect to sequelize
- Create four models
User,Post,Comment, andLike - Define appropriate associations between the models
- Create unit tests to ensure connection works, models function properly, and association are set up correctly.
- In
db/connection.js, create a sequelize connection to a database. - In
models/User.js, define aUsermodel with the following properties:username: A stringemail: A string
- In
models/Profile.js, create aProfilemodel with the following properties:bio: A stringprofilePicture: A stringbirthday: A date formatted as a string
- In
models/Post.js, create aPostmodel with the following properties:title: A stringbody: A stringcreatedAt: A date formatted as a string
- In
models/Comment.js, create aCommentbody: A stringcreatedAt: A date formatted as a string
- In
models/Like.js, create aLikemodel with the following properties:reactionType: A stringcreatedAt: A date formatted as a string
- In
index.js, define the following associations:- A
Usercan have oneProfileand vice versa. - A
Usercan have manyPostinstances, but aPostcan only have oneUser. - A
Postcan have manyCommentinstances, but aCommentcan only have onePost. - A
Usercan have manyLikeinstances and vice versa.
- A
- Write unit tests to ensure that the connection works and the associations are set up correctly.
- Seed data has been created in the
seeddirectory. Feel free to use this in your test creation!
- Seed data has been created in the
