1const userSchema = new Schema({
2 nick_name:{type:String},
3 email: {
4 type: String,
5 trim: true,
6 required: '{PATH} is required!',
7 index: true,
8 },
9 comments: [{ type: Schema.Types.ObjectId, ref:'Comment' }],
10 posts: [{ type: Schema.Types.ObjectId, ref:'Post' }]
11}, {timestamps: true});
12
13mongoose.model('User', userSchema);