//文章
let articalSchema = new mongoose.Schema({
title: String,
author: {
type:mongoose.Schema.Types.ObjectId,
ref:'user'
},
tag:[{
tid:{
type:mongoose.Schema.Types.ObjectId,
ref:'tag'
}
}],
status:Boolean,
comment:[{
cid:{
type:mongoose.Schema.Types.ObjectId,
ref:'comment'
}
}]
})
let commentSchema = new mongoose.Schema({
comment:String,
from_uid:{
type:mongoose.Schema.Types.ObjectId,
ref:'user'
}
})
let userSchema = new mongoose.Schema({
name:String
})
能一次性的把文章下面的comment里的from_uid关联的user表的内容查出来吗
用
populate
,下面是示例代码输出结果: