Optional
_idOptional
aliasDefines a virtual with the given name that gets/sets this path.
Optional
autoIf true, uses Mongoose's default _id
settings. Only allowed for ObjectIds
Optional
castAllows overriding casting logic for this individual path. If a string, the given string overwrites Mongoose's default cast error message.
Optional
defaultThe default value for this path. If a function, Mongoose executes the function and uses the return value as the default.
Optional
enumarray of allowed values for this path. Allowed for strings, numbers, and arrays of strings
Optional
message?: stringOptional
excludeIf true
, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.
Optional
expiresDefines a TTL index on this path. Only allowed for dates.
Optional
getdefines a custom getter for this property using Object.defineProperty()
.
Optional
doc: MixedSchemaTypeOptions<EnforcedDocType>Optional
Optional
immutableIf 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.
Optional
indexIf truthy, Mongoose will build an index on this path when the model is compiled.
Optional
lowercaseIf truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase()
.
Optional
matchAttaches a validator that succeeds if the data string matches the given regular expression, and fails otherwise.
Optional
maxThe maximum value allowed for this path. Only allowed for numbers and dates.
Optional
maxlengthIf set, Mongoose will add a custom validator that ensures the given string's length
is at most the given number.
Optional
minThe minimum value allowed for this path. Only allowed for numbers and dates.
Optional
minlengthIf set, Mongoose will add a custom validator that ensures the given string's length
is at least the given number.
Optional
ofIf set, specifies the type of this map's values. Mongoose will cast this map's values to the given type.
Optional
refThe model that populate()
should use if populating this path.
Optional
refThe path in the document that populate()
should use to find the model
to use.
Optional
requiredIf 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.
Optional
selectWhether to include or exclude this path by default when loading documents
using find()
, findOne()
, etc.
Optional
setdefines a custom setter for this property using Object.defineProperty()
.
Optional
priorVal: mongoose.Schema.Types.MixedOptional
Optional
doc: MixedSchemaTypeOptions<EnforcedDocType>Optional
Optional
sparseIf truthy, Mongoose will build a sparse index on this path.
Optional
subtypeThe default subtype associated with this buffer when it is stored in MongoDB. Only allowed for buffer paths
Optional
textIf truthy, Mongoose will build a text index on this path.
Optional
transformOptional
trimIf truthy, Mongoose will add a custom setter that removes leading and trailing whitespace using JavaScript's built-in String#trim()
.
Optional
uniqueIf truthy, Mongoose
will build a unique index on this path when the
model is compiled. The unique
option is not a validator.
Optional
uppercaseIf truthy, Mongoose will add a custom setter that uppercases this string using JavaScript's built-in String#toUpperCase()
.
Optional
validateFunction or object describing how to validate this schematype. See validation docs.
Generated using TypeDoc
If set, overrides the child schema's
_id
option. Only allowed for subdocuments and subdocument arrays.