schema «Schema» path «String» options «Object» Single nested subdocument SchemaType constructor.
getter «Function» Attaches a getter for all SubdocumentPath instances
name «String» schema «Schema» fields to add to the schema for instances of this sub-class [options] «Object|string» If string, same as options.value. [options.value] «String» the string stored in the discriminatorKey property. If not specified, Mongoose uses the name parameter. [options.clone=true] «Boolean» By default, discriminator() clones the given schema. Set to false to skip cloning. 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 }));
option «String» The option you'd like to set the value for value «Any» value for option Sets a default option for all SubdocumentPath instances.
// Make all numbers have option `min` equal to 0.
mongoose.Schema.SubdocumentPath.set('required', true);
© 2010 LearnBoost
Licensed under the MIT License.
https://mongoosejs.com/docs/api/subdocumentpath.html