collection.bulkWrite
Perform 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 } }
{ deleteOne: { filter: {c:1} } }
{ deleteMany: { filter: {c:1} } }
{ replaceOne: { filter: {c:3}, replacement: {c:4}, upsert:true}}
Arguments
operations
(Array) - Bulk operations to perform.[
options
] (Object)[
callback
] (function)
Returns
A promise.
Example
users.bulkWrite([
{ insertOne: { document: { a: 1 } } }
, { updateOne: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } }
, { updateMany: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } }
, { deleteOne: { filter: {c:1} } }
, { deleteMany: { filter: {c:1} } }
, { replaceOne: { filter: {c:3}, replacement: {c:4}, upsert:true}}
])