<?xml version="1.0"?>

<page id="mongoc_database_t"
      type="guide"
      style="class"
      xmlns="http://projectmallard.org/1.0/"
      xmlns:api="http://projectmallard.org/experimental/api/"
      xmlns:ui="http://projectmallard.org/experimental/ui/">
  <info>
    <link type="guide" xref="index#api-reference" />
  </info>

  <title>mongoc_database_t</title>
  <subtitle>MongoDB Database Abstraction</subtitle>

  <section id="description">
    <title>Synopsis</title>
    <screen><code mime="text/x-csrc"><![CDATA[typedef struct _mongoc_database_t mongoc_database_t;]]></code></screen>
    <p><code>mongoc_database_t</code> provides access to a MongoDB database. This handle is useful for actions a particular database object. It <em>is not</em> a container for <code xref="mongoc_collection_t">mongoc_collection_t</code> structures.</p>
    <p>Read preferences and write concerns are inherited from the parent client. They can be overridden with <code xref="mongoc_database_set_read_prefs">mongoc_database_set_read_prefs()</code> and <code xref="mongoc_database_set_write_concern">mongoc_database_set_write_concern()</code>.</p>
    <note style="warning"><p>It is an error to call <code
    xref="mongoc_database_destroy">mongoc_database_destroy()</code> on a
    database that has operations pending. It is required that you release <code
    xref="mongoc_cursor_t">mongoc_cursor_t</code> structures before calling
    <code xref="mongoc_database_destroy">mongoc_database_destroy</code>.
    </p></note>
  </section>

  <links type="topic" groups="function" style="2column">
    <title>Functions</title>
  </links>

  <section id="examples">
    <title>Examples</title>
    <screen><code mime="text/x-csrc"><![CDATA[#include <mongoc.h>

int
main (int argc,
      char *argv[])
{
   mongoc_database_t *database;
   mongoc_client_t *client;

   mongoc_init ();

   client = mongoc_client_new ("mongodb://localhost/");
   database = mongoc_client_get_database (client, "test");

   mongoc_database_destroy (database);
   mongoc_client_destroy (client);

   mongoc_cleanup ();

   return 0;
}
]]></code></screen>
  </section>
</page>
