A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mongodb.github.io/node-mongodb-native/3.6/api/UnorderedBulkOperation.html below:

Class: UnorderedBulkOperation

Class: UnorderedBulkOperation

Create a new UnorderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly)

Properties:
Name Type Description length number

Get the number of operations in the bulk.

Returns: UnorderedBulkOperation instance.
Extends Methods
inherited execute(_writeConcern, options, callback){Promise|void}

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 Description 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.

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: Returns: Promise if no callback passed

Builds a find operation for an update/updateOne/delete/deleteOne/replaceOne.
Returns a builder object used to complete the definition of the operation.

Name Type Description selector object

The selector for the bulk operation. See q documentation

Throws:

if a selector is not specified

Type
MongoError
Returns: helper object with which the write operation can be defined.
Example

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 Description document object

the document to insert

Throws: Returns: reference to self
Example

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 Description op object

The raw operation to perform.

options.hint object optional

An optional hint for query optimization. See the update command reference for more information.

Returns: reference to self

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