Define the following fields in the Comment schema:
title: String (Required) - Title of the comment.
content: String - Content of the comment.
author: Schema.Types.ObjectId (Reference to User, Required) - User who authored the comment.
blob: Number (Default: 0) - Additional metadata field for future use.
Schema Options:
Enable toJSON virtuals for the schema to transform the document data when serialized.
Create Model:
Use mongoose.model() to create the Comment model from the schema.
Export Model:
Export the Comment model for use in other parts of the application.
Define the following fields in the Comment schema: title: String (Required) - Title of the comment. content: String - Content of the comment. author: Schema.Types.ObjectId (Reference to User, Required) - User who authored the comment. blob: Number (Default: 0) - Additional metadata field for future use. Schema Options:
Enable toJSON virtuals for the schema to transform the document data when serialized. Create Model:
Use mongoose.model() to create the Comment model from the schema. Export Model:
Export the Comment model for use in other parts of the application.