Create a new UnorderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly)
length
number
Get the number of operations in the bulk.
Execute the bulk operation
Name Type Description_writeConcern
WriteConcern optional
Optional write concern. Can also be specified through options.
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.
fsync
boolean false optional
Deprecated Specify a file sync write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
callback
BulkOperationBase~resultCallback optional
A callback that will be invoked when bulkWrite finishes/errors
Throws error if the bulk object has already been executed
Throws error if the bulk object does not have any operations
Builds a find operation for an update/updateOne/delete/deleteOne/replaceOne.
Returns a builder object used to complete the definition of the operation.
selector
object
The selector for the bulk operation. See q documentation
if a selector is not specified
const bulkOp = collection.initializeOrderedBulkOp();
// Add an updateOne to the bulkOp
bulkOp.find({ a: 1 }).updateOne({ $set: { b: 2 } });
// Add an updateMany to the bulkOp
bulkOp.find({ c: 3 }).update({ $set: { d: 4 } });
// Add an upsert
bulkOp.find({ e: 5 }).upsert().updateOne({ $set: { f: 6 } });
// Add a deletion
bulkOp.find({ g: 7 }).deleteOne();
// Add a multi deletion
bulkOp.find({ h: 8 }).delete();
// Add a replaceOne
bulkOp.find({ i: 9 }).replaceOne({ j: 10 });
// Update using a pipeline (requires Mongodb 4.2 or higher)
bulk.find({ k: 11, y: { $exists: true }, z: { $exists: true } }).updateOne([
{ $set: { total: { $sum: [ '$y', '$z' ] } } }
]);
// All of the ops will now be executed
await bulkOp.execute();
Add a single insert document to the bulk operation
Name Type Descriptiondocument
object
the document to insert
const bulkOp = collection.initializeOrderedBulkOp();
// Adds three inserts to the bulkOp.
bulkOp
.insert({ a: 1 })
.insert({ b: 2 })
.insert({ c: 3 });
await bulkOp.execute();
Specifies a raw operation to perform in the bulk write.
Name Type Descriptionop
object
The raw operation to perform.
options.hint
object optional
An optional hint for query optimization. See the update command reference for more information.
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