---
name: "mongoc_collection_copy"
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_copy"
---

# mongoc\_collection\_copy(3)

## SYNOPSIS

```
mongoc_collection_t *
mongoc_collection_copy (mongoc_collection_t *collection);
```

## PARAMETERS

- •

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

## DESCRIPTION

Performs a deep copy of the **collection** struct and its configuration. Useful if you intend to call *mongoc\_collection\_set\_write\_concern()*, *mongoc\_collection\_set\_read\_prefs()*, or *mongoc\_collection\_set\_read\_concern()*, and want to preserve an unaltered copy of the struct.

This function does *not* copy the contents of the collection on the MongoDB server.

## RETURNS

A newly allocated *mongoc\_collection\_t* that should be freed with *mongoc\_collection\_destroy()* when no longer in use.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
