Empty object that you can use for storing properties on the document. This is handy for passing data to middleware without conflicting with Mongoose internals.
A string containing the current operation that Mongoose is executing
on this document. Can be null, 'save', 'validate', or 'remove'.
Set this property to add additional query filters when Mongoose saves this document and isNew is false.
OptionalbaseIf this is a discriminator model, baseModelName is the name of the base model.
Collection the model uses.
Connection the model uses.
OptionalerrorsReturns the current validation errors.
Boolean flag specifying if the document is new.
The document's schema.
Clear the document's modified paths.
Returns a deep clone of this document
Creates a snapshot of this document's internal change tracking state. You can later
reset this document's change tracking state using $restoreModifiedPathsSnapshot().
Returns an array of all populated documents associated with the query
Don't run validation on this path or persist changes to this path.
Increments the numeric value at path by the given val.
When you call save() on this document, Mongoose will send a
$inc as opposed to a $set.
Optionalval: numberChecks if a path is set to its default. If no path set, checks if any path is set to its default.
Optionalpath: stringGetter/setter, determines whether the document was removed or not.
Optionalval: booleanReturns true if the given path is nullish or only contains empty objects. Useful for determining whether this subdoc will get stripped out by the minimize option.
Checks if a path is invalid
Marks a path as valid, removing existing validation errors.
Returns the model with the given name on this document's associated connection.
Returns the model with the given name on this document's associated connection.
If this document is a subdocument or populated document, returns the document's parent. Returns undefined otherwise.
Restore this document's change tracking state to the given snapshot.
Note that $restoreModifiedPathsSnapshot() does not modify the document's
properties, just resets the change tracking state.
Getter/setter around the session associated with this document. Used to
automatically set session if you save() a doc that you got from a
query with an associated session.
Optionalsession: ClientSession | nullAlias for set(), used internally to avoid conflicts
Optionaloptions: DocumentSetOptionsAlias for set(), used internally to avoid conflicts
Optionaloptions: DocumentSetOptionsAlias for set(), used internally to avoid conflicts
Removes this document from the db.
Optionaloptions: QueryOptions<unknown>Returns the list of paths that have been directly modified. A direct
modified path is a path that you explicitly set, whether via doc.foo = 'bar',
Object.assign(doc, { foo: 'bar' }), or doc.set('foo', 'bar').
Returns true if this document is equal to another document.
Documents are considered equal when they have matching _ids, unless neither
document has an _id, in which case this function falls back to using
deepEqual().
Returns the value of a path.
Optionaltype: anyOptionaloptions: anyReturns the value of a path.
Optionaltype: anyOptionaloptions: anySignal that we desire an increment of this documents version.
Initializes the document without setters or marking anything modified. Called internally after a document is returned from mongodb. Normally, you do not need to call this function on your own.
Optionalopts: AnyObjectMarks a path as invalid, causing validation to fail.
Optionalvalue: anyOptionalkind: stringMarks a path as invalid, causing validation to fail.
Optionalvalue: anyOptionalkind: stringReturns true if path was directly set and modified, else false.
Checks if path was explicitly selected. If no projection, always returns true.
Checks if path was explicitly selected. If no projection, always returns true.
Checks if path is in the init state, that is, it was set by Document#init() and not modified since.
Checks if path is in the init state, that is, it was set by Document#init() and not modified since.
Returns true if any of the given paths are modified, else false. If no arguments, returns true if any path
in this document is modified.
Optionalpath: string | string[]Optionaloptions: { ignoreAtomics?: boolean } | nullChecks if path was selected in the source query which initialized this document.
Checks if path was selected in the source query which initialized this document.
Marks the path as having pending changes to write to the db.
Optionalscope: anyMarks the path as having pending changes to write to the db.
Optionalscope: anyReturns the model with the given name on this document's associated connection.
Returns the model with the given name on this document's associated connection.
Returns the list of paths that have been modified.
Optionaloptions: { includeChildren?: boolean }Overwrite all values in this document with the values of obj, except
for immutable properties. Behaves similarly to set(), except for it
unsets all properties that aren't in obj.
Gets _id(s) used during population of the given path. If the path was not populated, returns undefined.
Saves this document by inserting a new document into the database if document.isNew is true, or sends an updateOne operation with just the modified paths if isNew is false.
Optionaloptions: SaveOptionsSets the value of a path, or many paths.
Optionaloptions: DocumentSetOptionsSets the value of a path, or many paths.
Optionaloptions: DocumentSetOptionsSets the value of a path, or many paths.
Optionaloptions: DocumentSetOptionsSets the value of a path, or many paths.
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
The return value of this method is used in calls to JSON.stringify(doc).
Optionaloptions: ToObjectOptions<The return value of this method is used in calls to JSON.stringify(doc).
Optionaloptions: ToObjectOptions<Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Converts this document into a plain-old JavaScript object (POJO).
Optionaloptions: ToObjectOptions<Clears the modified state on the specified path.
Clears the modified state on the specified path.
Executes registered validation rules for this document.
OptionalpathsToValidate: PathsToValidateOptionaloptions: AnyObjectExecutes registered validation rules for this document.
Executes registered validation rules (skipping asynchronous validators) for this document.
Executes registered validation rules (skipping asynchronous validators) for this document.
OptionalpathsToValidate: PathsToValidateOptionaloptions: AnyObject
This documents _id.