April 2020
Intermediate to advanced
716 pages
18h 55m
English
To define the structure for storing details about each post and to store each post as a document in a collection in MongoDB, we will define the Mongoose schema for a post in server/models/post.model.js. The Post schema will store a post's text content, a photo, a reference to the user who posted, time of creation, likes on the post from users, and comments on the post by users. The schema will store these details in the following fields, each defined as shown with the corresponding code.
text: { type: String, required: 'Text is required'}
Read now
Unlock full access