Function or object describing how to validate this schematype. See validation docs.
Allows overriding casting logic for this individual path. If a string, the given string overwrites Mongoose's default cast error message.
If true, attach a required validator to this path, which ensures this path path cannot be set to a nullish value. If a function, Mongoose calls the function and only checks for nullish values if the function returns a truthy value.
The default value for this path. If a function, Mongoose executes the function and uses the return value as the default.
The model that populate()
should use if populating this path.
The path in the document that populate()
should use to find the model
to use.
Whether to include or exclude this path by default when loading documents
using find()
, findOne()
, etc.
If truthy, Mongoose will build an index on this path when the model is compiled.
If truthy, Mongoose
will build a unique index on this path when the
model is compiled. The unique
option is not a validator.
If truthy, Mongoose will disallow changes to this path once the document is saved to the database for the first time. Read more about immutability in Mongoose here.
If truthy, Mongoose will build a sparse index on this path.
If truthy, Mongoose will build a text index on this path.
Define a transform function for this individual schema type.
Only called when calling toJSON()
or toObject()
.
defines a custom getter for this property using Object.defineProperty()
.
defines a custom setter for this property using Object.defineProperty()
.
array of allowed values for this path. Allowed for strings, numbers, and arrays of strings
The default subtype associated with this buffer when it is stored in MongoDB. Only allowed for buffer paths
The minimum value allowed for this path. Only allowed for numbers and dates.
The maximum value allowed for this path. Only allowed for numbers and dates.
Defines a TTL index on this path. Only allowed for dates.
If true
, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.
If set, overrides the child schema's _id
option. Only allowed for subdocuments and subdocument arrays.
If set, specifies the type of this map's values. Mongoose will cast this map's values to the given type.
If true, uses Mongoose's default _id
settings. Only allowed for ObjectIds
Attaches a validator that succeeds if the data string matches the given regular expression, and fails otherwise.
If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase()
.
If truthy, Mongoose will add a custom setter that removes leading and trailing whitespace using JavaScript's built-in String#trim()
.
If truthy, Mongoose will add a custom setter that uppercases this string using JavaScript's built-in String#toUpperCase()
.
If set, Mongoose will add a custom validator that ensures the given string's length
is at least the given number.
If set, Mongoose will add a custom validator that ensures the given string's length
is at most the given number.
Generated using TypeDoc
Defines a virtual with the given name that gets/sets this path.