key «String» schema «Schema» options «Object» schemaOptions «Object» SubdocsArray SchemaType constructor
getter «Function» Attaches a getter for all DocumentArrayPath instances
Options for all document arrays.
castNonArrays: true by default. If false, Mongoose will throw a CastError when a value isn't an array. If true, Mongoose will wrap the provided value in an array before casting.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 document array.
const shapeSchema = Schema({ name: String }, { discriminatorKey: 'kind' });
const schema = Schema({ shapes: [shapeSchema] });
const docArrayPath = parentSchema.path('shapes');
docArrayPath.discriminator('Circle', Schema({ radius: Number }));
This schema type's name, to defend against minifiers that mangle function names.
option «String» The name of the option you'd like to set (e.g. trim, lowercase, etc...) value «Any» The value of the option you'd like to set. Sets a default option for all DocumentArray instances.
// Make all numbers have option `min` equal to 0.
mongoose.Schema.DocumentArray.set('_id', false);
© 2010 LearnBoost
Licensed under the MIT License.
https://mongoosejs.com/docs/api/documentarraypath.html