假设我有以下架构:
new Schema({
fruitType: {
type: String,
enum: ['apple', 'orange', 'melon', 'mango'],
required: true,
},
fruitValue: [ appleSchema ],
})
当 fruitType
为 apple 时,我希望 fruitValue
为 appleSchema
,当它为 melon 时,我希望该字段具有 melonSchema
。 Mongoose 有没有办法做到这一点?