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 aUser
model with the following properties:username
: A stringemail
: A string
- In
models/Profile.js
, create aProfile
model with the following properties:bio
: A stringprofilePicture
: A stringbirthday
: A date formatted as a string
- In
models/Post.js
, create aPost
model with the following properties:title
: A stringbody
: A stringcreatedAt
: A date formatted as a string
- In
models/Comment.js
, create aComment
body
: A stringcreatedAt
: A date formatted as a string
- In
models/Like.js
, create aLike
model with the following properties:reactionType
: A stringcreatedAt
: A date formatted as a string
- In
index.js
, define the following associations:- A
User
can have oneProfile
and vice versa. - A
User
can have manyPost
instances, but aPost
can only have oneUser
. - A
Post
can have manyComment
instances, but aComment
can only have onePost
. - A
User
can have manyLike
instances 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
seed
directory. Feel free to use this in your test creation!
- Seed data has been created in the