There's a new kind of operations in 2.6 that's called bulk operations. It resembles me transactions - user can specify a set of writes and subsequently execute them just like described below
var bulk = db.users.initializeOrderedBulkOp();
bulk.insert( { user: "abc123", status: "A", points: 0 } );
bulk.insert( { user: "ijk123", status: "A", points: 0 } );
bulk.insert( { user: "mop123", status: "P", points: 0 } );
bulk.find( { status: "D" } ).remove();
bulk.find( { status: "P" } ).update( { $set: { comment: "Pending" } } );
bulk.execute();
Is bulk operation atomic? Does a potential consumer experiences non-repeatable or phantom reads?
From mongo docs: Operations on a single document are always atomic with MongoDB databases, however, operations that involve multiple documents, which are often referred to as "multi-document transactions", are not atomic.
Bulk write operations can be either ordered or unordered. With an ordered list of operations, MongoDB executes the operations serially. If an error occurs during the processing of one of the write operations, MongoDB will return without processing any remaining write operations in the list
.
http://docs.mongodb.org/manual/core/bulk-write-operations/
Conclusion: there is no transaction in bulk operations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With