,
line 100Create a new Collection instance (INTERNAL TYPE, do not instantiate directly)
The name of this collection
The name of the database this collection belongs to
The current index hint for the collection
The namespace of this collection, in the format ${this.dbName}.${this.collectionName}
The current readConcern of the collection. If not explicitly defined for
this collection, will be inherited from the parent DB
The current readPreference of the collection. If not explicitly defined for
this collection, will be inherited from the parent DB
The current writeConcern of the collection. If not explicitly defined for
this collection, will be inherited from the parent DB
,
line 1910Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
Name Type Default Descriptionpipeline
object [] optional
Array containing all the aggregation framework commands for the execution.
options
object optional
Optional settings.
Name Type Default DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
batchSize
number 1000 optional
The number of documents to return per batch. See aggregation documentation.
cursor
object optional
Return the query as cursor, on 2.6 > it returns as a real cursor on pre 2.6 it returns as an emulated cursor.
Name Type Default DescriptionbatchSize
number 1000 optional
Deprecated. Use options.batchSize
allowDiskUse
boolean false optional
allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 >).
maxTimeMS
number optional
maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.
maxAwaitTimeMS
number optional
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
raw
boolean false optional
Return document results as raw BSON buffers.
promoteLongs
boolean true optional
Promotes Long values to number if they fit inside the 53 bits resolution.
promoteValues
boolean true optional
Promotes BSON values to native types where possible, set to false to only receive wrapper types.
promoteBuffers
boolean false optional
Promotes Binary BSON values to native Node Buffers.
collation
object optional
Specify collation settings for operation. See aggregation documentation.
comment
string optional
Add a comment to an aggregation command
hint
string | object optional
Add an index selection hint to an aggregation command
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~aggregationCallback
The command result callback
,
line 612Perform a bulkWrite operation without a fluent API
Legal operation types are
{ insertOne: { document: { a: 1 } } }
{ updateOne: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } }
{ updateMany: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } }
{ updateMany: { filter: {}, update: {$set: {"a.$[i].x": 5}}, arrayFilters: [{ "i.x": 5 }]} }
{ deleteOne: { filter: {c:1} } }
{ deleteMany: { filter: {c:1} } }
{ replaceOne: { filter: {c:3}, replacement: {c:4}, upsert:true}}
If documents passed in do not contain the _id field,
one will be added to each of the documents missing it by the driver, mutating the document. This behavior
can be overridden by setting the forceServerObjectId flag.
operations
Array.<object>
Bulk operations to perform.
options
object optional
Optional settings.
Name Type Default Descriptionordered
boolean true optional
Execute write operation in ordered or unordered fashion.
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
arrayFilters
Array.<object> optional
Determines which array elements to modify for update operation in MongoDB 3.6 or higher.
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
session
ClientSession optional
optional session to use for this operation
callback
Collection~bulkWriteOpCallback optional
The command result callback
,
line 1516An estimated count of matching documents in the db to a query.
NOTE: This method has been deprecated, since it does not provide an accurate count of the documents
in a collection. To obtain an accurate count of documents in the collection, use countDocuments
.
To obtain an estimated count of all documents in the collection, use estimatedDocumentCount
.
query
object {} optional
The query for the count.
options
object optional
Optional settings.
Name Type Descriptioncollation
object optional
Specify collation settings for operation. See aggregation documentation.
limit
boolean optional
The limit of documents to count.
skip
boolean optional
The number of documents to skip for the count.
hint
string optional
An index name hint for the query.
readPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
session
ClientSession optional
optional session to use for this operation
callback
Collection~countCallback optional
The command result callback
countDocuments
or estimatedDocumentCount
instead,
line 1583Gets the number of documents matching the filter.
For a fast count of the total documents in a collection see estimatedDocumentCount
.
Note: When migrating from count
to countDocuments
the following query operators must be replaced:
$where
$expr
$near
$geoWithin
with $center
$nearSphere
$geoWithin
with $centerSphere
Name Type Description query
object optional
the query for the count
options
object optional
Optional settings.
Name Type Descriptioncollation
object optional
Specifies a collation.
hint
string | object optional
The index to use.
limit
number optional
The maximum number of document to count.
maxTimeMS
number optional
The maximum amount of time to allow the operation to run.
skip
number optional
The number of documents to skip before counting.
callback
Collection~countCallback optional
The command result callback.
,
line 1243Creates an index on the db and collection collection.
Name Type DescriptionfieldOrSpec
string | array | object
Defines the index.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
unique
boolean false optional
Creates an unique index.
sparse
boolean false optional
Creates a sparse index.
background
boolean false optional
Creates the index in the background, yielding whenever possible.
dropDups
boolean false optional
A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value
min
number optional
For geospatial indexes set the lower bound for the co-ordinates.
max
number optional
For geospatial indexes set the high bound for the co-ordinates.
v
number optional
Specify the format version of the indexes.
expireAfterSeconds
number optional
Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher)
name
string optional
Override the autogenerated index name (useful if the resulting name is larger than 128 bytes)
partialFilterExpression
object optional
Creates a partial index based on the given filter object (MongoDB 3.2 or higher)
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
session
ClientSession optional
optional session to use for this operation
commitQuorum
number | string optional
(MongoDB 4.4. or higher) Specifies how many data-bearing members of a replica set, including the primary, must complete the index builds successfully before the primary marks the indexes as ready. This option accepts the same values for the "w" field in a write concern plus "votingMembers", which indicates all voting data-bearing nodes.
callback
Collection~resultCallback optional
The command result callback
const collection = client.db('foo').collection('bar');
await collection.createIndex({ a: 1, b: -1 });
// Alternate syntax for { c: 1, d: -1 } that ensures order of indexes
await collection.createIndex([ [c, 1], [d, -1] ]);
// Equivalent to { e: 1 }
await collection.createIndex('e');
// Equivalent to { f: 1, g: 1 }
await collection.createIndex(['f', 'g'])
// Equivalent to { h: 1, i: -1 }
await collection.createIndex([ { h: 1 }, { i: -1 } ]);
// Equivalent to { j: 1, k: -1, l: 2d }
await collection.createIndex(['j', ['k', -1], { l: '2d' }])
,
line 1296Creates multiple indexes in the collection, this method is only supported for
MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported
error.
Note: Unlike createIndex
, this function takes in raw index specifications.
Index specifications are defined here.
indexSpecs
Array.<Collection~IndexDefinition>
An array of index specifications to be created
options
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
commitQuorum
number | string optional
(MongoDB 4.4. or higher) Specifies how many data-bearing members of a replica set, including the primary, must complete the index builds successfully before the primary marks the indexes as ready. This option accepts the same values for the "w" field in a write concern plus "votingMembers", which indicates all voting data-bearing nodes.
callback
Collection~resultCallback optional
The command result callback
const collection = client.db('foo').collection('bar');
await collection.createIndexes([
// Simple index on field fizz
{
key: { fizz: 1 },
}
// wildcard index
{
key: { '$**': 1 }
},
// named index on darmok and jalad
{
key: { darmok: 1, jalad: -1 }
name: 'tanagra'
}
]);
,
line 960Delete multiple documents from a collection
Name Type Descriptionfilter
object
The Filter used to select the documents to remove
options
object optional
Optional settings.
Name Type Default Descriptioncollation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
hint
string | object optional
optional index hint for optimizing the filter query
callback
Collection~deleteWriteOpCallback optional
The command result callback
,
line 924Delete a document from a collection
Name Type Descriptionfilter
object
The Filter used to select the document to remove
options
object optional
Optional settings.
Name Type Default Descriptioncollation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
hint
string | object optional
optional index hint for optimizing the filter query
callback
Collection~deleteWriteOpCallback optional
The command result callback
,
line 1608The distinct command returns a list of distinct values for the given key across a collection.
Name Type Descriptionkey
string
Field of the document to find distinct values for.
query
object optional
The query for filtering the set of documents to which we apply the distinct filter.
options
object optional
Optional settings.
Name Type DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
collation
object optional
Specify collation settings for operation. See aggregation documentation.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1150Drop the collection from the database, removing it permanently. New accesses will create a new collection.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The results callback
,
line 1367Drops all indexes from this collection.
Name Type Descriptioncallback
Collection~resultCallback
The command result callback
,
line 1327Drops an index from this collection.
Name Type DescriptionindexName
string
Name of the index to drop.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
session
ClientSession optional
optional session to use for this operation
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
callback
Collection~resultCallback optional
The command result callback
,
line 1349Drops all indexes from this collection.
Name Type Descriptionoptions
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
callback
Collection~resultCallback optional
The command result callback
,
line 1435Ensures that an index exists, if it does not it creates it
Name Type DescriptionfieldOrSpec
string | object
Defines the index.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
unique
boolean false optional
Creates an unique index.
sparse
boolean false optional
Creates a sparse index.
background
boolean false optional
Creates the index in the background, yielding whenever possible.
dropDups
boolean false optional
A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value
min
number optional
For geospatial indexes set the lower bound for the co-ordinates.
max
number optional
For geospatial indexes set the high bound for the co-ordinates.
v
number optional
Specify the format version of the indexes.
expireAfterSeconds
number optional
Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher)
name
number optional
Override the autogenerated index name (useful if the resulting name is larger than 128 bytes)
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1542Gets an estimate of the count of documents in a collection using collection metadata.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type DescriptionmaxTimeMS
number optional
The maximum amount of time to allow the operation to run.
callback
Collection~countCallback optional
The command result callback.
,
line 318Creates a cursor for a query that can be used to iterate over results from MongoDB
Name Type Default Descriptionquery
object {} optional
The cursor query object.
options
object optional
Optional settings.
Name Type Default Descriptionlimit
number 0 optional
Sets the limit of documents returned in the query.
sort
array | object optional
Set to sort the documents coming back from the query. Array of indexes, [['a', 1]] etc.
projection
object optional
The fields to return in the query. Object of fields to either include or exclude (one of, not both), {'a':1, 'b': 1} or {'a': 0, 'b': 0}
fields
object optional
Deprecated Use options.projection
instead
skip
number 0 optional
Set to skip N documents ahead in your query (useful for pagination).
hint
Object optional
Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1}
snapshot
boolean false optional
DEPRECATED: Snapshot query.
timeout
boolean false optional
Specify if the cursor can timeout.
tailable
boolean false optional
Specify if the cursor is tailable.
awaitData
boolean false optional
Specify if the cursor is a a tailable-await cursor. Requires tailable
to be true
batchSize
number 1000 optional
Set the batchSize for the getMoreCommand when iterating over the query results.
returnKey
boolean false optional
Only return the index key.
maxScan
number optional
DEPRECATED: Limit the number of items to scan.
min
number optional
Set index bounds.
max
number optional
Set index bounds.
showDiskLoc
boolean false optional
Show disk location of results.
comment
string optional
You can put a $comment field on a query to make looking in the profiler logs simpler.
raw
boolean false optional
Return document results as raw BSON buffers.
promoteLongs
boolean true optional
Promotes Long values to number if they fit inside the 53 bits resolution.
promoteValues
boolean true optional
Promotes BSON values to native types where possible, set to false to only receive wrapper types.
promoteBuffers
boolean false optional
Promotes Binary BSON values to native Node Buffers.
readPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
partial
boolean false optional
Specify if the cursor should return partial results when querying against a sharded system
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
maxAwaitTimeMS
number optional
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires tailable
and awaitData
to be true
noCursorTimeout
boolean optional
The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
allowDiskUse
boolean optional
Enables writing to temporary files on the server.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
,
line 1824Find and update a document.
Name Type Descriptionquery
object
Query object to locate the object to modify.
sort
array
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
doc
object
The fields/vals to be updated.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
remove
boolean false optional
Set to true to remove the object before returning.
upsert
boolean false optional
Perform an upsert operation.
new
boolean false optional
Set to true if you want to return the modified object rather than the original. Ignored for remove.
projection
object optional
Object containing the field projection for the result returned from the operation.
fields
object optional
Deprecated Use options.projection
instead
session
ClientSession optional
optional session to use for this operation
arrayFilters
Array optional
optional list of array filters referenced in filtered positional operators
callback
Collection~findAndModifyCallback optional
The command result callback
,
line 1869Find and remove a document.
Name Type Descriptionquery
object
Query object to locate the object to modify.
sort
array
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1087Fetches the first document that matches the query
Name Type Descriptionquery
object
Query for find Operation
options
object optional
Optional settings.
Name Type Default Descriptionlimit
number 0 optional
Sets the limit of documents returned in the query.
sort
array | object optional
Set to sort the documents coming back from the query. Array of indexes, [['a', 1]] etc.
projection
object optional
The fields to return in the query. Object of fields to include or exclude (not both), {'a':1}
fields
object optional
Deprecated Use options.projection
instead
skip
number 0 optional
Set to skip N documents ahead in your query (useful for pagination).
hint
Object optional
Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1}
snapshot
boolean false optional
DEPRECATED: Snapshot query.
timeout
boolean false optional
Specify if the cursor can timeout.
tailable
boolean false optional
Specify if the cursor is tailable.
batchSize
number 1 optional
Set the batchSize for the getMoreCommand when iterating over the query results.
returnKey
boolean false optional
Only return the index key.
maxScan
number optional
DEPRECATED: Limit the number of items to scan.
min
number optional
Set index bounds.
max
number optional
Set index bounds.
showDiskLoc
boolean false optional
Show disk location of results.
comment
string optional
You can put a $comment field on a query to make looking in the profiler logs simpler.
raw
boolean false optional
Return document results as raw BSON buffers.
promoteLongs
boolean true optional
Promotes Long values to number if they fit inside the 53 bits resolution.
promoteValues
boolean true optional
Promotes BSON values to native types where possible, set to false to only receive wrapper types.
promoteBuffers
boolean false optional
Promotes Binary BSON values to native Node Buffers.
readPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
partial
boolean false optional
Specify if the cursor should return partial results when querying against a sharded system
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1688Find a document and delete it in one atomic operation. Requires a write lock for the duration of the operation.
Name Type Descriptionfilter
object
The Filter used to select the document to remove
options
object optional
Optional settings.
Name Type Default Descriptioncollation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
projection
object optional
Limits the fields to return for all matching documents.
sort
object optional
Determines which document the operation modifies if the query selects multiple documents.
maxTimeMS
number optional
The maximum amount of time to allow the query to run.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~findAndModifyCallback optional
The collection result callback
,
line 1729Find a document and replace it in one atomic operation. Requires a write lock for the duration of the operation.
Name Type Descriptionfilter
object
The Filter used to select the document to replace
replacement
object
The Document that replaces the matching document
options
object optional
Optional settings.
Name Type Default DescriptionbypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
hint
string | object optional
An optional index to use for this operation
maxTimeMS
number optional
The maximum amount of time to allow the query to run.
projection
object optional
Limits the fields to return for all matching documents.
sort
object optional
Determines which document the operation modifies if the query selects multiple documents.
upsert
boolean false optional
Upsert the document if it does not exist.
returnDocument
'before' | 'after' 'before' optional
When set to 'after'
, returns the updated document rather than the original. The default is 'before'
.
returnOriginal
boolean true optional
Deprecated Use options.returnDocument
instead.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~findAndModifyCallback optional
The collection result callback
,
line 1778Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.
Name Type Descriptionfilter
object
The Filter used to select the document to update
update
object
Update operations to be performed on the document
options
object optional
Optional settings.
Name Type Default DescriptionarrayFilters
Array optional
optional list of array filters referenced in filtered positional operators
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
hint
string | object optional
An optional index to use for this operation
maxTimeMS
number optional
The maximum amount of time to allow the query to run.
projection
object optional
Limits the fields to return for all matching documents.
sort
object optional
Determines which document the operation modifies if the query selects multiple documents.
upsert
boolean false optional
Upsert the document if it does not exist.
returnDocument
'before' | 'after' 'before' optional
When set to 'after'
, returns the updated document rather than the original. The default is 'before'
.
returnOriginal
boolean true optional
Deprecated Use options.returnDocument
instead.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
An ptional session to use for this operation
callback
Collection~findAndModifyCallback optional
The collection result callback
,
line 2050Execute a geo search using a geo haystack index on a collection.
Name Type Descriptionx
number
Point to search on the x axis, ensure the indexes are ordered in the same order.
y
number
Point to search on the y axis, ensure the indexes are ordered in the same order.
options
object optional
Optional settings.
Name Type Default DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
maxDistance
number optional
Include results up to maxDistance from the point.
search
object optional
Filter the results by a query.
limit
number false optional
Max number of results to return.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 2077Run a group command across a collection
Name Type Descriptionkeys
object | array | function | code
An object, array or function expressing the keys to group by.
condition
object
An optional condition that must be true for a row to be considered.
initial
object
Initial value of the aggregation counter object.
reduce
function | Code
The reduce function aggregates (reduces) the objects iterated
finalize
function | Code
An optional function to be run on each item in the result set just before the item is returned.
command
boolean
Specify if you wish to run using the internal group command or using eval, default is true.
options
object optional
Optional settings.
Name Type DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1627Retrieve all the indexes on the collection.
Name Type Descriptionoptions
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1456Checks if one or more indexes exist on the collection, fails on first non-existing index
Name Type Descriptionindexes
string | array
One or more index names to check.
options
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1474Retrieves this collections index info.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Default Descriptionfull
boolean false optional
Returns the full raw index information.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 2220Initiate an In order bulk write operation. Operations will be serially executed in the order they are added, creating a new operation for each switch in types.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
session
ClientSession optional
optional session to use for this operation
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
,
line 2196Initiate an Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
session
ClientSession optional
optional session to use for this operation
,
line 695Inserts a single document or a an array of documents into MongoDB. If documents passed in do not contain the _id field,
one will be added to each of the documents missing it by the driver, mutating the document. This behavior
can be overridden by setting the forceServerObjectId flag.
docs
object | Array.<object>
Documents to insert.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
serializeFunctions
boolean false optional
Serialize functions on any object.
forceServerObjectId
boolean false optional
Force server to assign _id values instead of driver.
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
session
ClientSession optional
optional session to use for this operation
callback
Collection~insertWriteOpCallback optional
The command result callback
,
line 544Inserts an array of documents into MongoDB. If documents passed in do not contain the _id field,
one will be added to each of the documents missing it by the driver, mutating the document. This behavior
can be overridden by setting the forceServerObjectId flag.
docs
Array.<object>
Documents to insert.
options
object optional
Optional settings.
Name Type Default DescriptionbypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
ordered
boolean true optional
If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails.
forceServerObjectId
boolean false optional
Force server to assign _id values instead of driver.
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean true optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
session
ClientSession optional
optional session to use for this operation
callback
Collection~insertWriteOpCallback optional
The command result callback
,
line 507Inserts a single document into MongoDB. If documents passed in do not contain the _id field,
one will be added to each of the documents missing it by the driver, mutating the document. This behavior
can be overridden by setting the forceServerObjectId flag.
doc
object
Document to insert.
options
object optional
Optional settings.
Name Type Default DescriptionbypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
forceServerObjectId
boolean false optional
Force server to assign _id values instead of driver.
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean true optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
session
ClientSession optional
optional session to use for this operation
callback
Collection~insertOneWriteOpCallback optional
The command result callback
,
line 1190Returns if the collection is a capped collection
Name Type Descriptionoptions
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The results callback
,
line 1401Get the list of all indexes information for the collection.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Default DescriptionbatchSize
number 1000 optional
The batchSize for the returned command cursor or if pre 2.8 the systems batch collection
readPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
session
ClientSession optional
optional session to use for this operation
,
line 2158Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
Name Type Descriptionmap
function | string
The mapping function.
reduce
function | string
The reduce function.
options
object optional
Optional settings.
Name Type Default DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
out
object optional
Sets the output target for the map reduce job. {inline:1} | {replace:'collectionName'} | {merge:'collectionName'} | {reduce:'collectionName'}
query
object optional
Query filter object.
sort
object optional
Sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces.
limit
number optional
Number of objects to return from collection.
keeptemp
boolean false optional
Keep temporary data.
finalize
function | string optional
Finalize function.
scope
object optional
Can pass in variables that can be access from map/reduce/finalize.
jsMode
boolean false optional
It is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X.
verbose
boolean false optional
Provide statistics on job execution time.
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 1172Returns the options of the collection.
Name Type Descriptionoptions
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The results callback
,
line 2009Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are
no ordering guarantees for returned results.
options
object optional
Optional settings.
Name Type Default DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
batchSize
number 1000 optional
Set the batchSize for the getMoreCommand when iterating over the query results.
numCursors
number 1 optional
The maximum number of parallel command cursors to return (the number of returned cursors will be in the range 1:numCursors)
raw
boolean false optional
Return all BSON documents as Raw Buffer documents.
callback
Collection~parallelCollectionScanCallback optional
The command result callback
,
line 1382Reindex all indexes on the collection
Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
options
Object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The command result callback
,
line 993Remove documents.
Name Type Descriptionselector
object
The selector for the update operation.
options
object optional
Optional settings.
Name Type Default Descriptioncollation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
single
boolean false optional
Removes the first document found.
session
ClientSession optional
optional session to use for this operation
callback
Collection~writeOpCallback optional
The command result callback
,
line 1128Rename the collection.
Name Type DescriptionnewName
string
New name of of the collection.
options
object optional
Optional settings.
Name Type Default DescriptiondropTarget
boolean false optional
Drop the target name collection if it previously exists.
session
ClientSession optional
optional session to use for this operation
callback
Collection~collectionResultCallback optional
The results callback
,
line 791Replace a document in a collection with another document
Name Type Descriptionfilter
object
The Filter used to select the document to replace
doc
object
The Document that replaces the matching document
options
object optional
Optional settings.
Name Type Default DescriptionbypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
hint
object optional
An optional hint for query optimization. See the update command reference for more information.
upsert
boolean false optional
When true, creates a new document if no document matches the query.
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
session
ClientSession optional
optional session to use for this operation
callback
Collection~updateWriteOpCallback optional
The command result callback
,
line 1026Save a document. Simple full document replacement function. Not recommended for efficiency, use atomic
operators and update instead for more efficient operations.
doc
object
Document to save
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
session
ClientSession optional
optional session to use for this operation
callback
Collection~writeOpCallback optional
The command result callback
,
line 1646Get all the collection statistics.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Descriptionscale
number optional
Divide the returned sizes by scale value.
session
ClientSession optional
optional session to use for this operation
callback
Collection~resultCallback optional
The collection result callback
,
line 870Updates documents.
Name Type Descriptionselector
object
The selector for the update operation.
update
object
The update operations to be applied to the documents
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
upsert
boolean false optional
Update operation is an upsert.
multi
boolean false optional
Update one/all documents with operation.
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
arrayFilters
Array optional
optional list of array filters referenced in filtered positional operators
session
ClientSession optional
optional session to use for this operation
hint
object optional
An optional hint for query optimization. See the update command reference for more information.
callback
Collection~writeOpCallback optional
The command result callback
,
line 831Update multiple documents in a collection
Name Type Descriptionfilter
object
The Filter used to select the documents to update
update
object
The update operations to be applied to the documents
options
object optional
Optional settings.
Name Type Default DescriptionarrayFilters
Array optional
optional list of array filters referenced in filtered positional operators
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
hint
object optional
An optional hint for query optimization. See the update command reference for more information.
upsert
boolean false optional
When true, creates a new document if no document matches the query..
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~updateWriteOpCallback optional
The command result callback
,
line 753Update a single document in a collection
Name Type Descriptionfilter
object
The Filter used to select the document to update
update
object
The update operations to be applied to the document
options
object optional
Optional settings.
Name Type Default DescriptionarrayFilters
Array optional
optional list of array filters referenced in filtered positional operators
bypassDocumentValidation
boolean false optional
Allow driver to bypass schema validation in MongoDB 3.2 or higher.
collation
object optional
Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
hint
object optional
An optional hint for query optimization. See the update command reference for more information.
upsert
boolean false optional
When true, creates a new document if no document matches the query..
w
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
checkKeys
boolean false optional
If true, will throw if bson documents start with $
or include a .
in any key value
serializeFunctions
boolean false optional
Serialize functions on any object.
ignoreUndefined
boolean false optional
Specify if the BSON serializer should ignore undefined fields.
explain
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean optional
The verbosity mode for the explain output.
session
ClientSession optional
optional session to use for this operation
callback
Collection~updateWriteOpCallback optional
The command result callback
,
line 1977Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.
Name Type Descriptionpipeline
Array optional
An array of aggregation pipeline stages through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
options
object optional
Optional settings
Name Type Default DescriptionfullDocument
string 'default' optional
Allowed values: ‘default’, ‘updateLookup’. When set to ‘updateLookup’, the change stream will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred.
resumeAfter
object optional
Specifies the logical starting point for the new change stream. This should be the _id field from a previously returned change stream document.
maxAwaitTimeMS
number optional
The maximum amount of time for the server to wait on new documents to satisfy a change stream query
batchSize
number 1000 optional
The number of documents to return per batch. See aggregation documentation.
collation
object optional
Specify collation settings for operation. See aggregation documentation.
readPreference
ReadPreference optional
The read preference. Defaults to the read preference of the database or collection. See read preference documentation.
startAtOperationTime
Timestamp optional
receive change events that occur after the specified timestamp
session
ClientSession optional
optional session to use for this operation
,
line 1046The callback format for an aggregation call
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
cursor
AggregationCursor
The cursor if the aggregation command was executed successfully.
,
line 565The callback format for inserts
Name Type Descriptionerror
BulkWriteError
An error instance representing the error during the execution.
result
Collection~BulkWriteOpResult
The result object if the command was executed successfully.
insertedCount
number
Number of documents inserted.
matchedCount
number
Number of documents matched for update.
modifiedCount
number
Number of documents modified.
deletedCount
number
Number of documents deleted.
upsertedCount
number
Number of documents upserted.
insertedIds
object
Inserted document generated Id's, hash key is the index of the originating operation
upsertedIds
object
Upserted document generated Id's, hash key is the index of the originating operation
result
object
The command result object.
,
line 1110The callback format for the collection method, must be used if strict is specified
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
collection
Collection
The collection instance.
,
line 1488The callback format for results
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
number
The count of documents that matched the query.
,
line 898The callback format for deletes
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
Collection~deleteWriteOpResult
The result object if the command was executed successfully.
result
Object
The raw result returned from MongoDB. Will vary depending on server version.
Properties Name Type Descriptionok
Number
Is 1 if the command executed correctly.
n
Number
The total count of documents deleted.
connection
Object
The connection object used for the operation.
deletedCount
Number
The number of documents deleted.
,
line 1663The callback format for inserts
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
Collection~findAndModifyWriteOpResult
The result object if the command was executed successfully.
value
object
Document returned from the findAndModify
command. If no documents were found, value
will be null
by default even if a document was upserted unless returnDocument
is specified as 'after'
, in which case the upserted document will be returned.
lastErrorObject
object
The raw lastErrorObject returned from the command. See findAndModify command documentation.
ok
Number
Is 1 if the command executed correctly.
A definition for an index. Used by the createIndex command.
,
line 668The callback format for inserts
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
Collection~insertOneWriteOpResult
The result object if the command was executed successfully.
insertedCount
number
The total amount of documents inserted.
ops
Array.<object>
All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany
insertedId
ObjectId
The driver generated ObjectId for the insert operation.
connection
object
The connection object used for the operation.
result
object
The raw command result object returned from MongoDB (content might vary by server version).
Properties Name Type Descriptionok
number
Is 1 if the command executed correctly.
n
number
The total count of documents inserted.
,
line 661The callback format for inserts
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
Collection~insertWriteOpResult
The result object if the command was executed successfully.
insertedCount
number
The total amount of documents inserted.
ops
Array.<object>
All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany
insertedIds
Object.<Number, ObjectId>
Map of the index of the inserted document to the id of the inserted document.
connection
object
The connection object used for the operation.
result
object
The raw command result object returned from MongoDB (content might vary by server version).
Properties Name Type Descriptionok
number
Is 1 if the command executed correctly.
n
number
The total count of documents inserted.
,
line 1990The callback format for results
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
cursors
Array.<Cursor>
A list of cursors returned allowing for parallel reading of collection.
,
line 1039The callback format for results
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
object
The result object if the command was executed successfully.
,
line 723The callback format for inserts
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
Collection~updateWriteOpResult
The result object if the command was executed successfully.
result
Object
The raw result returned from MongoDB. Will vary depending on server version.
Properties Name Type Descriptionok
Number
Is 1 if the command executed correctly.
n
Number
The total count of documents scanned.
nModified
Number
The total count of documents modified.
connection
Object
The connection object used for the operation.
matchedCount
Number
The number of documents that matched the filter.
modifiedCount
Number
The number of documents that were modified.
upsertedCount
Number
The number of documents upserted.
upsertedId
Object
The upserted id.
Properties Name Type Description_id
ObjectId
The upserted _id returned from the server.
message
Object
The raw msg response wrapped in an internal class
ops
Array.<object> <optional>
In a response to replaceOne
, contains the new value of the document on the server. This is the same document that was originally passed in, and is only here for legacy purposes.
,
line 632The callback format for inserts
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
Collection~WriteOpResult
The result object if the command was executed successfully.
ops
Array.<object>
All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany
connection
object
The connection object used for the operation.
result
object
The command result object.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4