<?xml version="1.0"?>

<page xmlns="http://projectmallard.org/1.0/"
      type="topic"
      style="function"
      xmlns:api="http://projectmallard.org/experimental/api/"
      xmlns:ui="http://projectmallard.org/experimental/ui/"
      id="mongoc_collection_create_bulk_operation">


  <info>
    <link type="guide" xref="mongoc_collection_t" group="function"/>
  </info>
  <title>mongoc_collection_create_bulk_operation()</title>

  <section id="synopsis">
    <title>Synopsis</title>
    <synopsis><code mime="text/x-csrc"><![CDATA[mongoc_bulk_operation_t *
mongoc_collection_create_bulk_operation (
      mongoc_collection_t          *collection,
      bool                          ordered,
      const mongoc_write_concern_t *write_concern)
   BSON_GNUC_WARN_UNUSED_RESULT;
]]></code></synopsis>
  </section>


  <section id="parameters">
    <title>Parameters</title>
    <table>
      <tr><td><p>collection</p></td><td><p>A <link xref="mongoc_collection_t">mongoc_collection_t</link>.</p></td></tr>
      <tr><td><p>ordered</p></td><td><p>If the operations must be performed in order.</p></td></tr>
      <tr><td><p>write_concern</p></td><td><p>An optional <link xref="mongoc_write_concern_t">mongoc_write_concern_t</link> or NULL.</p></td></tr>
    </table>
  </section>

  <section id="description">
    <title>Description</title>
    <p>This function shall begin a new bulk operation. After creating this you may call various functions such as <link xref="mongoc_bulk_operation_update">mongoc_bulk_operation_update()</link>, <link xref="mongoc_bulk_operation_insert">mongoc_bulk_operation_insert()</link> and others.</p>
    <p>After calling <link xref="mongoc_bulk_operation_execute">mongoc_bulk_operation_execute()</link> the commands will be executed in as large as batches as reasonable by the client.</p>
    <p>If <code>ordered</code> is true, then processing will stop at the first error.</p>
    <p>If <code>ordered</code> is not true, then the bulk operation will attempt to continue processing even after the first failure.</p>
    <p><code>write_concern</code> should contain the write concern you wish to have applied to all operations within the bulk operation.</p>
  </section>

  <section id="errors">
    <title>Errors</title>
    <p>Errors are propagated when executing the bulk operation.</p>
  </section>

  <section id="return">
    <title>Returns</title>
    <p>A newly allocated <link xref="mongoc_bulk_operation_t">mongoc_bulk_operation_t</link> that should be freed with <link xref="mongoc_bulk_operation_destroy">mongoc_bulk_operation_destroy()</link> when no longer in use.</p>
    <note style="warning"><p>Failure to handle the result of this function is a programming error.</p></note>
  </section>


</page>
