mongoc_write_concern_t

Write Concern abstraction

Synopsis

mongoc_write_concern_t tells the driver what level of acknowledgment to await from the server. The default, MONGOC_WRITE_CONCERN_W_DEFAULT, is right for the great majority of applications.

You can specify a write concern on connection objects, database objects, collection objects, or per-operation.

See Write Concern on the MongoDB website for more information.

Write Concern Levels

Network Related

MONGOC_WRITE_CONCERN_W_DEFAULT (1)

By default, writes block awaiting acknowledgment from MongoDB. Acknowledged write concern allows clients to catch network, duplicate key, and other errors.

MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED (-1)

With this write concern, MongoDB does not acknowledge write operations. The client cannot detect failed write operations due to connection errors, or server errors such as duplicate key exceptions for unique indexes. This write concern provides fast performance at the cost of significant risks for data persistence and durability.

MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED (0)

With this write concern, MongoDB does not acknowledge the receipt of write operation. Unacknowledged is similar to errors ignored; however, mongoc attempts to receive and handle network errors when possible.

MONGOC_WRITE_CONCERN_W_MAJORITY (majority)

Block until a write has been propagated to a majority of the nodes in the replica set.

n

Block until a write has been propagated to at least n nodes in the replica set.

Node Persistence

journal

Block until the node receiving the write has committed the journal.