<?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_save">
  <info>
    <link type="guide" xref="mongoc_collection_t" group="function"/>
  </info>
  <title>mongoc_collection_save()</title>

  <section id="synopsis">
    <title>Synopsis</title>
    <synopsis><code mime="text/x-csrc"><![CDATA[bool
mongoc_collection_save (mongoc_collection_t          *collection,
                        const bson_t                 *document,
                        const mongoc_write_concern_t *write_concern,
                        bson_error_t                 *error);
]]></code></synopsis>
  </section>

  <section id="parameters">
    <title>Parameters</title>
    <table>
      <tr><td><p>collection</p></td><td><p>A <code xref="mongoc_collection_t">mongoc_collection_t</code>.</p></td></tr>
      <tr><td><p>document</p></td><td><p>A <code xref="bson:bson_t">bson_t</code> containing the document.</p></td></tr>
      <tr><td><p>write_concern</p></td><td><p>A <code xref="mongoc_write_concern_t">mongoc_write_concern_t</code> or <code>NULL</code> for default write concern.</p></td></tr>
      <tr><td><p>error</p></td><td><p>An optional location for a <code xref="bson:bson_error_t">bson_error_t</code> or <code>NULL</code>.</p></td></tr>
    </table>
  </section>

  <section id="description">
    <title>Description</title>
    <p>This function shall save a document into <code>collection</code>. If the document has an <code>_id</code> field it will be updated. Otherwise it will be inserted.</p>
  </section>

  <section id="errors">
    <title>Errors</title>
    <p>Errors are propagated via the <code>error</code> parameter.</p>
  </section>

  <section id="return">
    <title>Returns</title>
    <p>true if successful, otherwise false and error is set.</p>
  </section>

</page>
