📜  猫鼬加入多个集合 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:00.404000             🧑  作者: Mango

代码示例2
const userSchema = new Schema({  
    nick_name:{type:String},  
    email: {  
        type: String,  
        trim: true,  
        required: '{PATH} is required!',
        index: true,
    },
    comments: [{ type: Schema.Types.ObjectId, ref:'Comment' }],
    posts: [{ type: Schema.Types.ObjectId, ref:'Post' }]
}, {timestamps: true});

mongoose.model('User', userSchema);