📌  相关文章
📜  如何从多个表中获取数据 mongoose - Javascript 代码示例

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

代码示例1
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);