MONGOC_WRITE_CONCERN_T(3)

πŸ’– NAME πŸ’–

mongoc_write_concern_t β€” the whole Write Concern abstraction, bestie. This is the libmongoc manual page for it, and it’s literally about telling the driver what level of acknowledgement to await from the server. ✨

🌸 SYNOPSIS 🌸

Okay so mongoc_write_concern_t tells the driver what level of acknowledgement to await from the server. The default, MONGOC_WRITE_CONCERN_W_DEFAULT, is right for the great majority of applications. No cap. 🫢

You can specify a write concern on connection objects, database objects, collection objects, or per-operation. Data-modifying operations typically use the write concern of the object they operate on, and check the server response for a write concern error or write concern timeout. For example, mongoc_collection_drop_index() uses the collection’s write concern, and a write concern error or timeout in the response is considered a failure. πŸ’…

Exceptions to this principle are the generic command functions:

  • mongoc_client_command_simple()
  • mongoc_database_command_simple()
  • mongoc_collection_command_simple()

These generic command functions do not automatically apply a write concern, and they do not check the server response for a write concern error or write concern timeout. Important vibe check, fr fr. πŸ‘‘

See Write Concern on the MongoDB website for more information.


✨ WRITE CONCERN LEVELS ✨

Set the write concern level with mongoc_write_concern_set_w(). Here’s the lineup, iconic and exact: 🌈

  • MONGOC_WRITE_CONCERN_W_DEFAULT (1) β€” By default, writes block awaiting acknowledgement from MongoDB. Acknowledged write concern allows clients to catch network, duplicate key, and other errors.
  • 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.
Bestie, that’s the whole write concern menu: default, unacknowledged, majority, or a specific n. Pick your main character setting wisely. πŸ¦‹

🫢 AUTHOR 🫢

MongoDB, Inc

2009-present, MongoDB, Inc.


Signed, sealed, delivered: libmongoc 2.5.6, dated Oct 09, 2026 β€” slay, go get those acknowledged writes πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from