The callback to execute when the Promise is rejected.
A Promise for the completion of the callback.
The model this query was created from
Attaches callbacks for the resolution and/or rejection of the Promise.
The callback to execute when the Promise is resolved.
The callback to execute when the Promise is rejected.
A Promise for the completion of which ever callback is executed.
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.
Executes the query
Sets the allowDiskUse option for the query (ignored for < 4.4.0)
Specifies arguments for an $and
condition.
Specifies the batchSize option.
Casts this query to the schema of model
.
the casted obj
Make a copy of this query so you can re-execute it.
Adds a collation to this op (MongoDB 3.4 and up)
Specifies the comment
option.
Specifies this query as a count
query.
Specifies this query as a countDocuments
query.
Returns a wrapper around a mongodb driver cursor.
A QueryCursor exposes a Streams3 interface, as well as a .next()
function.
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
.
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.
Creates a distinct
query: returns the distinct values of the given field
that match filter
.
Gets/sets the error flag on this query. If this flag is not null or
undefined, the exec()
promise will reject without executing.
Specifies the complementary comparison value for paths specified with where()
Creates a estimatedDocumentCount
query: counts the number of documents in the collection.
Specifies a $exists
query condition. When called with one argument, the most recent path passed to where()
is used.
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.
Creates a find
query: gets a list of documents that match filter
.
Declares the query a findOne operation. When executed, the first found document is passed to the callback.
Creates a findOneAndDelete
query: atomically finds the given document, deletes it, and returns the document as it was before deletion.
Creates a findOneAndRemove
query: atomically finds the given document and deletes it.
Creates a findOneAndUpdate
query: atomically find the first document that matches filter
and apply update
.
Declares the query a findById operation. When executed, the document with the given _id
is passed to the callback.
Creates a findByIdAndDelete
query, filtering by the given _id
.
Creates a findOneAndUpdate
query, filtering by the given _id
.
Specifies a $geometry
condition
For update operations, returns the value of a path in the update's $set
.
Useful for writing getters/setters that can work with both update operations
and save()
.
Returns the current query filter (also known as conditions) as a POJO.
Gets query options.
Gets a list of paths to be populated by this query
Returns the current query filter. Equivalent to getFilter()
.
Returns the current update operations as a JSON object.
Sets query hints.
Declares an intersects query for geometry()
.
Requests acknowledgement that this operation has been persisted to MongoDB's on-disk journal.
Sets the lean option.
Specifies the maximum number of documents the query will return.
Runs a function fn
and treats the return value of fn
as the new value
for the query to resolve to.
Specifies the maxScan option.
Merges another Query or conditions object into this one.
Specifies a $mod
condition, filters documents for documents whose path
property is a number that is equal to remainder
modulo divisor
.
Getter/setter around the current mongoose-specific options for this query Below are the current Mongoose-specific options.
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.
Specifies paths which should be populated with other documents.
Get/set the current projection (AKA fields). Pass null
to remove the current projection.
Determines the MongoDB nodes from which to read.
Sets the readConcern option for the query.
Specifies a $regex
query condition. When called with one argument, the most recent path passed to where()
is used.
Declare and/or execute this query as a remove() operation. remove()
is
deprecated, you should use deleteOne()
or deleteMany()
instead.
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.)
Specifies which document fields to include or exclude (also known as the query "projection")
Determines if field selection has been made.
Determines if exclusive field selection has been made.
Determines if inclusive field selection has been made.
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.
Sets query options. Some options only make sense for certain operations.
Sets the query conditions to the provided JSON object.
Specifies an $size
query condition. When called with one argument, the most recent path passed to where()
is used.
Specifies the number of documents to skip.
Specifies this query as a snapshot
query.
Sets the tailable option (for use with capped collections).
Converts this query to a customized, reusable query constructor with all arguments and options retained.
Declare and/or execute this query as an update() operation.
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.
Declare and/or execute this query as an updateOne() operation. Same as
update()
, except it does not support the multi
or overwrite
options.
Sets the specified number of mongod
servers, or tag set of mongod
servers,
that must acknowledge this write before this write is considered successful.
Defines a $within
or $geoWithin
argument for geo-spatial queries.
Generated using TypeDoc
Attaches a callback for only the rejection of the Promise.