Executes the query returning a Promise which will be
resolved with .finally() chained.
Optional onfinally: (() => void)The model this query was created from
Executes the query returning a Promise which will be
resolved with either the doc(s) or rejected with the error.
Returns a wrapper around a mongodb driver cursor.
A QueryCursor exposes a Streams3 interface, as well as a .next() function.
This is equivalent to calling .cursor() with no arguments.
Specifies arguments for an $and condition.
Adds a collation to this op (MongoDB 3.4 and up)
Specifies this query as a count query.
Optional criteria: FilterQuery<RawDocType>Specifies this query as a countDocuments query.
Optional criteria: FilterQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Returns a wrapper around a mongodb driver cursor.
A QueryCursor exposes a Streams3 interface, as well as a .next() function.
Optional options: mongoose.QueryOptions<DocType>Declare and/or execute this query as a deleteMany() operation. Works like
remove, except it deletes every document that matches filter in the
collection, regardless of the value of single.
Optional filter: FilterQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Declare and/or execute this query as a deleteOne() operation. Works like
remove, except it deletes at most one document regardless of the single
option.
Optional filter: FilterQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Creates a distinct query: returns the distinct values of the given field that match filter.
Optional filter: FilterQuery<RawDocType>Creates a estimatedDocumentCount query: counts the number of documents in the collection.
Optional options: mongoose.QueryOptions<DocType>Executes the query
Sets the explain option,
which makes this query return detailed execution stats instead of the actual
query result. This method is useful for determining what index your queries
use.
Optional verbose: ExplainVerbosityLikeCreates a find query: gets a list of documents that match filter.
Optional projection: ProjectionType<RawDocType>Optional options: mongoose.QueryOptions<DocType>Optional projection: ProjectionType<RawDocType>Declares the query a findById operation. When executed, returns the document with the given _id.
Optional projection: ProjectionType<RawDocType>Optional options: mongoose.QueryOptions<DocType>Optional projection: ProjectionType<RawDocType>Creates a findByIdAndDelete query, filtering by the given _id.
Optional id: anyOptional options: mongoose.QueryOptions<DocType>Creates a findOneAndUpdate query, filtering by the given _id.
Optional id: anyOptional update: UpdateQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Declares the query a findOne operation. When executed, returns the first found document.
Optional filter: FilterQuery<RawDocType>Optional projection: ProjectionType<RawDocType>Optional options: mongoose.QueryOptions<DocType>Optional filter: FilterQuery<RawDocType>Optional projection: ProjectionType<RawDocType>Optional filter: FilterQuery<RawDocType>Creates a findOneAndDelete query: atomically finds the given document, deletes it, and returns the document as it was before deletion.
Optional filter: FilterQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Creates a findOneAndRemove query: atomically finds the given document and deletes it.
Optional filter: FilterQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Creates a findOneAndUpdate query: atomically find the first document that matches filter and apply update.
Optional filter: FilterQuery<RawDocType>Optional update: UpdateQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Returns the current query filter (also known as conditions) as a POJO.
Gets query options.
Returns the current query filter. Equivalent to getFilter().
Returns the current update operations as a JSON object.
Sets the lean option.
Optional val: anySets the maxTimeMS
option. This will tell the MongoDB server to abort if the query or write op
has been running for more than ms milliseconds.
Merges another Query or conditions object into this one.
Getter/setter around the current mongoose-specific options for this query Below are the current Mongoose-specific options.
Optional val: MongooseQueryOptions<unknown>Specifies arguments for an $nor condition.
Specifies arguments for an $or condition.
Make this query throw an error if no documents match the given filter.
This is handy for integrating with async/await, because orFail() saves you
an extra if statement to check if no document was found.
Optional err: NativeError | (() => NativeError)Specifies paths which should be populated with other documents.
Get/set the current projection (AKA fields). Pass null to remove the current projection.
Optional fields: string | ProjectionFields<DocType>Declare and/or execute this query as a replaceOne() operation. Same as
update(), except MongoDB will replace the existing document and will
not accept any atomic operators ($set, etc.)
Optional filter: FilterQuery<RawDocType>Optional replacement: AnyObject | DocTypeOptional options: mongoose.QueryOptions<DocType>Specifies which document fields to include or exclude (also known as the query "projection")
Sets the MongoDB session associated with this query. Sessions are how you mark a query as part of a transaction.
Adds a $set to this query's update without changing the operation.
This is useful for query middleware so you can add an update regardless
of whether you use updateOne(), updateMany(), findOneAndUpdate(), etc.
Optional value: anySets query options. Some options only make sense for certain operations.
Optional overwrite: booleanSets the query conditions to the provided JSON object.
Runs a function fn and treats the return value of fn as the new value
for the query to resolve to.
Declare and/or execute this query as an updateMany() operation. Same as
update(), except MongoDB will update all documents that match
filter (as opposed to just the first one) regardless of the value of
the multi option.
Optional filter: FilterQuery<RawDocType>Optional update: UpdateWithAggregationPipeline | UpdateQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>Declare and/or execute this query as an updateOne() operation. Same as
update(), except it does not support the multi or overwrite options.
Optional filter: FilterQuery<RawDocType>Optional update: UpdateWithAggregationPipeline | UpdateQuery<RawDocType>Optional options: mongoose.QueryOptions<DocType>If w > 1, the maximum amount of time to
wait for this write to propagate through the replica set before this
operation fails. The default is 0, which means no timeout.
Executes the query returning a
Promisewhich will be resolved with either the doc(s) or rejected with the error. Like.then(), but only takes a rejection handler.