【发布时间】:2018-12-21 18:48:33
【问题描述】:
我有一个对象数组。我想保存集合中的某些部分,并引用第二个集合来检索补充数据
集合 1
statute: [{
_id: { type: ObjectId, ref: "Statute" },
subsection: [{
header: String,
}],
}],
使用 .populate("statute._id", "title statute") 我希望得到以下输出:
"statute": [
{
"subsection": [],
"_id": "5c15bcf348549e2aac5e99d3",
"title": 13,
"statute": 103
},
]
但我收到的输出是
"statute": [
{
"subsection": [],
"_id": {
"_id": "5c15bcf348549e2aac5e99d3",
"title": 13,
"statute": 103
}
},
如何告诉 Mongoose 根据 statute._id 进行填充,但返回 statute 中的值?
【问题讨论】: