Complete the code to initialize an unordered bulk operation on the 'users' collection.
const bulk = db.collection('users').[1]();
The method initializeUnorderedBulkOp() starts an unordered bulk operation on a collection.
Complete the code to add an insert operation for a document with name 'Alice' to the bulk operation.
bulk.[1]({ name: 'Alice' });
The insert() method adds an insert operation to the bulk operation.
Fix the error in the code to update a document where name is 'Bob' by setting age to 30 in the bulk operation.
bulk.find({ name: 'Bob' }).updateOne({ [1]: { age: 30 } });The update operator $set is required to set fields in MongoDB update operations.
Fill both blanks to add a delete operation for documents where status is 'inactive' and then execute the bulk operation.
bulk.find({ status: 'inactive' }).[1]();
const result = bulk.[2]();find({ status: 'inactive' }).remove() adds a delete operation for multiple documents, and execute() runs the bulk operations.
Fill all three blanks to add an update operation that increments 'score' by 5 for a document where 'level' is 10, then add an insert for a new user, and finally execute the bulk operation.
bulk.find({ level: 10 }).[1]({ [2]: { score: 5 } });
bulk.[3]({ name: 'Charlie', level: 1 });
const res = bulk.execute();updateOne() updates a single document, $inc increments a field, and insert() adds a new document to the bulk operation.