---
name: "mongoc_write_concern_t"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_write_concern_t"
---

# mongoc\_write\_concern\_t(3)

Write Concern abstraction

## SYNOPSIS

**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.

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()*

- •

  *mongoc\_client\_command\_simple()*

- •

  *mongoc\_database\_command()*

- •

  *mongoc\_database\_command\_simple()*

- •

  *mongoc\_collection\_command()*

- •

  *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.

See *Write Concern* on the MongoDB website for more information.

## WRITE CONCERN LEVELS

Set the write concern level with *mongoc\_write\_concern\_set\_w()*.

| | |
| --- | --- |
| 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. |

## DEPRECATIONS

The write concern **MONGOC\_WRITE\_CONCERN\_W\_ERRORS\_IGNORED** (value -1) is a deprecated synonym for **MONGOC\_WRITE\_CONCERN\_W\_UNACKNOWLEDGED** (value 0), and will be removed in the next major release.

*mongoc\_write\_concern\_set\_fsync()* is deprecated.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
