Optional
doc: anyOptional
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.
Optional
__vThis documents __v.
Optional
_idThis documents _id.
Optional
baseIf this is a discriminator model, baseModelName
is the name of the base model.
Collection the model uses.
Connection the model uses.
Optional
errorsReturns the current validation errors.
Optional
idThe string version of this documents _id.
Boolean flag specifying if the document is new.
The document's schema.
Assert that a given path or paths is populated. Throws an error if not populated.
Optional
values: Partial<Paths>Optional
Returns a deep clone of this document
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
.
Optional
val: numberOptional
Returns 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.
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.
Optional
session: mongoose.mongo.ClientSessionOptional
Alias for set()
, used internally to avoid conflicts
Optional
options: DocumentSetOptionsOptional
Optional
options: DocumentSetOptionsOptional
Removes this document from the db.
Optional
options: mongoose.QueryOptions<unknown>Optional
Takes a populated field and returns it to its unpopulated state. If called with no arguments, then all populated fields are returned to their unpopulated state.
Optional
path: string | string[]Optional
Returns the value of a path.
Optional
type: anyOptional
Optional
options: anyOptional
Optional
type: anyOptional
Optional
options: anyOptional
Returns the changes that happened to the document in the format that will be sent to MongoDB.
Signal 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.
Marks a path as invalid, causing validation to fail.
Optional
value: anyOptional
Optional
kind: stringOptional
Optional
value: anyOptional
Optional
kind: stringOptional
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.
Optional
path: T | T[]Optional
Optional
options: { Optional
Optional
ignoreOptional
path: string | string[]Optional
Optional
options: { Optional
Optional
ignoreMarks the path as having pending changes to write to the db.
Optional
scope: anyOptional
Optional
scope: anyOptional
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
.
Returns this sub-documents parent array.
Populates document references.
Optional
select: string | AnyObjectOptional
Optional
model: mongoose.Model<any, {}, {}, {}, any, any>Optional
Optional
match: AnyObjectOptional
Optional
options: PopulateOptionsOptional
Sends a replaceOne command with this document _id
as the query selector.
Optional
replacement: AnyObjectOptional
Optional
options: mongoose.QueryOptions<unknown>Optional
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
.
Optional
options: SaveOptionsOptional
Sets the value of a path, or many paths.
Optional
options: DocumentSetOptionsOptional
Optional
options: DocumentSetOptionsOptional
Optional
options: DocumentSetOptionsOptional
The return value of this method is used in calls to JSON.stringify(doc).
Optional
options: ToObjectOptions<mongoose.Document<unknown, {}, unknown> & Required<{ Optional
Converts this document into a plain-old JavaScript object (POJO).
Optional
options: ToObjectOptions<mongoose.Document<unknown, {}, unknown> & Required<{ Optional
Sends an updateOne command with this document _id
as the query selector.
Optional
update: UpdateWithAggregationPipeline | UpdateQuery<ArraySubdocument<IdType, TQueryHelpers, DocType>>Optional
Optional
options: mongoose.QueryOptions<unknown>Optional
Executes registered validation rules for this document.
Optional
pathsToValidate: T | T[]Optional
Optional
options: AnyObjectOptional
Optional
pathsToValidate: PathsToValidateOptional
Optional
options: AnyObjectOptional
Optional
pathsExecutes registered validation rules (skipping asynchronous validators) for this document.
Optional
pathsOptional
pathsToValidate: T | T[]Optional
Optional
options: AnyObjectOptional
Optional
pathsToValidate: PathsToValidateOptional
Optional
options: AnyObjectOptional
Generated using TypeDoc
Generic types for Document: