0

I have a Mongoose offer model explained below:

const OfferSchema = new Schema({
  sections: [
    {
      title: String,
    },
  ],
});

and order schema which has reference to to the first schema offer explained below:

const OrderSchema = new Schema({
  offers: [
    {
      offer: { type: Schema.Types.ObjectId, ref: 'Offer' },
      sections: [
        {
          section: { type: Schema.Types.ObjectId, ref: 'Offer.sections' }, // issue here
        },
      ],
    },
  ],
});

the problem that I can not populate sections here {section: { type: Schema.Types.ObjectId, ref: 'Offer.sections' }}

it gives me MissingSchemaError: Schema hasn't been registered for model "Offer.sections".

so is there any way to populate sections?

1 Answer 1

1

Unfortunately, Mongoose doesn't support this feature. check the Github issue here

The alternative solution you can embed sections into the order schema

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.