---
name: "mongoc_database_create_collection"
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_database_create_collection"
---

# mongoc\_database\_create\_collection(3)

## SYNOPSIS

```
mongoc_collection_t *
mongoc_database_create_collection (mongoc_database_t *database,
                                   const char *name,
                                   const bson_t *opts,
                                   bson_error_t *error);
```

## PARAMETERS

- •

  **database**: A *mongoc\_database\_t*.

- •

  **name**: The name of the new collection.

- •

  **opts**: An optional *bson\_t* for opts to the **create** command.

- •

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

## DESCRIPTION

This function creates a *mongoc\_collection\_t* from the given *mongoc\_database\_t*.

If no write concern is provided in **opts**, the database's write concern is used.

The **encryptedFields** document in **opts** may be used to create a collection used for *Queryable Encryption*.

For a list of all options, see *the MongoDB Manual entry on the create command*.

## ERRORS

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

## RETURNS

This function returns a newly allocated *mongoc\_collection\_t* upon success, **NULL** upon failure and **error** is set.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
