【发布时间】:2017-01-04 15:37:30
【问题描述】:
SampleModel:
{
"Name": String,
"brandid": {
type: Schema.ObjectId,
ref: 'BrandList.BrandItems',
}
}
品牌型号:
{
"BrandName" : String,
"BrandItems": [{
"KG": Number,
"_id" : {type: Schema.ObjectId}
}]
}
如何将子文档数组的 ObjectId 引用到另一个模型,以及如何将 populate() 用于此“brandid”?
【问题讨论】:
标签: mongodb mongoose mongodb-query