---
name: "mongoc_collection_create_bulk_operation_with_opts"
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_create_bulk_operation_with_opts"
---

# mongoc\_collection\_create\_bulk\_operation\_with\_opts(3)

## SYNOPSIS

```
mongoc_bulk_operation_t *
mongoc_collection_create_bulk_operation_with_opts (
   mongoc_collection_t *collection,
   const bson_t *opts);
```

## PARAMETERS

- •

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

**opts** may be NULL or a BSON document with additional command options:

- •

  **writeConcern**: Construct a *mongoc\_write\_concern\_t* and use *mongoc\_write\_concern\_append()* to add the write concern to **opts**. See the example code for *mongoc\_client\_write\_command\_with\_opts()*.

- •

  **ordered**: set to **false** to attempt to insert all documents, continuing after errors.

- •

  **sessionId**: First, construct a *mongoc\_client\_session\_t* with *mongoc\_client\_start\_session()*. You can begin a transaction with *mongoc\_client\_session\_start\_transaction()*, optionally with a *mongoc\_transaction\_opt\_t* that overrides the options inherited from **collection**, and use *mongoc\_client\_session\_append()* to add the session to **opts**. See the example code for *mongoc\_client\_session\_t*.

- •

  **let**: A BSON document consisting of any number of parameter names, each followed by definitions of constants in the MQL Aggregate Expression language.

- •

  **comment**: A *bson\_value\_t* specifying the comment to attach to this command. The comment will appear in log messages, profiler output, and currentOp output. Requires MongoDB 4.4 or later.

## DESCRIPTION

This function shall begin a new bulk operation. After creating this you may call various functions such as *mongoc\_bulk\_operation\_update()*, *mongoc\_bulk\_operation\_insert()* and others.

After calling *mongoc\_bulk\_operation\_execute()* the commands will be executed in as large as batches as reasonable by the client.

## ERRORS

Errors are propagated when executing the bulk operation.

## RETURNS

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

**WARNING:**

Failure to handle the result of this function is a programming error.

**SEE ALSO:**

```
Bulk Write Operations
```

```
mongoc_bulk_operation_t
```

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
