[英]Mongoose populate subdocument in array
我有一个猫鼬报价模型解释如下:
const OfferSchema = new Schema({
sections: [
{
title: String,
},
],
});
和 order 架构参考下面解释的第一个架构报价:
const OrderSchema = new Schema({
offers: [
{
offer: { type: Schema.Types.ObjectId, ref: 'Offer' },
sections: [
{
section: { type: Schema.Types.ObjectId, ref: 'Offer.sections' }, // issue here
},
],
},
],
});
我无法在此处填充部分的问题{section: { type: Schema.Types.ObjectId, ref: 'Offer.sections' }}
它给了我MissingSchemaError: Schema hasn't been registered for model "Offer.sections".
那么有没有办法填充部分?
不幸的是,Mongoose 不支持此功能。 在此处检查 Github 问题
您可以将部分嵌入订单模式的替代解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.