Single nested subdocument SchemaType constructor.
discriminatorKey
property. If not specified, Mongoose uses the name
parameter. Adds a discriminator to this single nested subdocument.
const shapeSchema = Schema({ name: String }, { discriminatorKey: 'kind' });
const schema = Schema({ shape: shapeSchema });
const singleNestedPath = parentSchema.path('shape');
singleNestedPath.discriminator('Circle', Schema({ radius: Number }));
© 2010 LearnBoost
Licensed under the MIT License.
https://mongoosejs.com/docs/api/singlenestedpath.html