'How to reference schema 1 or shema 2 in mongodb?

How to tell Shema 3 is array item to reference Schema 1 or 2 ?

const model3Schema = new mongoose.Schema(
  {
    name: { type: String, required: true },
    items: [
        {
        model: { type: String },
        modelId: {
          type: ObjectId,
          required: true,
          ref: 'model1' // or   ref: 'model2'
        }
      }
    ]
  },
  { timestamps: true }
);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source