---
name: "mongoc_collection_update"
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_collection_update"
---

# mongoc\_collection\_update(3)

## SYNOPSIS

```
bool
mongoc_collection_update (mongoc_collection_t *collection,
                          mongoc_update_flags_t flags,
                          const bson_t *selector,
                          const bson_t *update,
                          const mongoc_write_concern_t *write_concern,
                          bson_error_t *error);
```

## PARAMETERS

- •

  **collection**: A *mongoc\_collection\_t*.

- •

  **flags**: A bitwise or of *mongoc\_update\_flags\_t*.

- •

  **selector**: A *bson\_t* containing the query to match documents for updating.

- •

  **update**: A *bson\_t* containing the update to perform. If updating with a pipeline, a *bson\_t* array.

- •

  **write\_concern**: A *mongoc\_write\_concern\_t*.

- •

  **error**: An optional location for a *bson\_error\_t* or **NULL**.

## DESCRIPTION

**NOTE:**

To pass additional options, use *mongoc\_collection\_update\_one()*, *mongoc\_collection\_update\_many()*, or *mongoc\_collection\_replace\_one()*.

This function shall update documents in **collection** that match **selector**.

By default, updates only a single document. Set flags to **MONGOC\_UPDATE\_MULTI\_UPDATE** to update multiple documents.

## ERRORS

Errors are propagated via the **error** parameter.

## RETURNS

Returns **true** if successful. Returns **false** and sets **error** if there are invalid arguments or a server or network error.

A write concern timeout or write concern error is considered a failure.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
