【发布时间】:2020-12-18 19:48:42
【问题描述】:
我有一个 Mongoose 报价模型,解释如下:
const OfferSchema = new Schema({
sections: [
{
title: String,
},
],
});
以及参考第一个模式报价的订单模式如下所述:
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".
那么有什么方法可以填充部分吗?
【问题讨论】:
标签: javascript node.js mongodb mongoose populate