SubdocsArray SchemaType constructor
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.discriminatorKey
property. If not specified, Mongoose uses the name
parameter. 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.
© 2010 LearnBoost
Licensed under the MIT License.
https://mongoosejs.com/docs/api/documentarraypath.html