猫鼬填充数组中的子文档

问题描述

我有以下解释的猫鼬报价模型:

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".

那么有什么方法可以填充节吗?

解决方法

不幸的是,猫鼬不支持此功能。 检查Github问题here

您可以将部分嵌入订单模式的替代解决方案

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...