MongoDB C++ Driver  mongocxx-3.0.0
Public Member Functions | List of all members
mongocxx::bulk_write Class Reference

Class representing a batch of write operations that can be sent to the server as a group. More...

#include <bulk_write.hpp>

Public Member Functions

 bulk_write (options::bulk_write options={})
 Initializes a new bulk operation to be executed against a mongocxx::collection. More...
 
 bulk_write (bulk_write &&) noexcept
 Move constructs a bulk write operation.
 
bulk_writeoperator= (bulk_write &&) noexcept
 Move assigns a bulk write operation.
 
 ~bulk_write ()
 Destroys a bulk write operation.
 
void append (const model::write &operation)
 Appends a single write to the bulk write operation. More...
 

Detailed Description

Class representing a batch of write operations that can be sent to the server as a group.

If you have a lot of write operations to execute, it can be more efficient to send them as part of a bulk_write in order to avoid unnecessary network-level round trips between the driver and the server.

Bulk writes affect a single collection only and are executed via the collection::bulk_write() method. Options that you would typically specify for individual write operations (such as write concern) are instead specified for the aggregate operation.

See also
http://docs.mongodb.org/manual/core/write-operations/
http://docs.mongodb.org/manual/core/bulk-write-operations/

Constructor & Destructor Documentation

mongocxx::bulk_write::bulk_write ( options::bulk_write  options = {})
explicit

Initializes a new bulk operation to be executed against a mongocxx::collection.

Parameters
orderedIf true all write operations will be executed serially in the order they were appended and the entire bulk operation will abort on the first error. If false operations will be executed in an arbitrary order (possibly in parallel on the server) and any errors will be reported after attempting all operations. Unordered bulk writes may be more efficient than ordered bulk writes.

Member Function Documentation

void mongocxx::bulk_write::append ( const model::write operation)

Appends a single write to the bulk write operation.

The write operation's contents are copied into the bulk operation completely, so there is no dependency between the life of an appended write operation and the bulk operation itself.

Parameters
operationThe write operation to append (an instance of model::write)

A model::write can be implicitly constructed from any of the following MongoDB models:


The documentation for this class was generated from the following file: