|
| 1 | +.. include:: /includes/unicode-checkmark.rst |
| 2 | + |
| 3 | +================ |
| 4 | +MongoDB C Driver |
| 5 | +================ |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: twocols |
| 14 | + |
| 15 | +Introduction |
| 16 | +------------ |
| 17 | + |
| 18 | +The MongoDB C Driver, also known as “libmongoc”, is the official client library |
| 19 | +for C applications, and provides a base for MongoDB drivers in higher-level |
| 20 | +languages. |
| 21 | + |
| 22 | +The library is compatible with all major platforms. It depends on libbson |
| 23 | +to create and parse BSON data. |
| 24 | + |
| 25 | +- `Tutorial <http://mongoc.org/libmongoc/current/tutorial.html>`__ |
| 26 | + |
| 27 | +- `Usage Guide <http://mongoc.org/libmongoc/current/index.html>`__ |
| 28 | + |
| 29 | +- `API Reference <http://mongoc.org/libmongoc/current/api.html>`_ |
| 30 | + |
| 31 | +- `Changelog <https://github.com/mongodb/mongo-c-driver/releases>`__ |
| 32 | + |
| 33 | +- `Source Code <https://github.com/mongodb/mongo-c-driver>`__ |
| 34 | + |
| 35 | + |
| 36 | +Installation |
| 37 | +------------ |
| 38 | + |
| 39 | +See `Installing the MongoDB C Driver (libmongoc) and BSON library (libbson) |
| 40 | +<http://mongoc.org/libmongoc/current/installing.html>`__. |
| 41 | + |
| 42 | + |
| 43 | +Connect to MongoDB Atlas |
| 44 | +------------------------ |
| 45 | + |
| 46 | +To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use the `Atlas connection string <https://docs.atlas.mongodb.com/driver-connection>`__ for your cluster: |
| 47 | + |
| 48 | +.. code-block:: c |
| 49 | + |
| 50 | + #include <mongoc/mongoc.h> |
| 51 | + |
| 52 | + int |
| 53 | + main (int argc, char *argv[]) |
| 54 | + { |
| 55 | + mongoc_database_t *database; |
| 56 | + mongoc_client_t *client; |
| 57 | + |
| 58 | + mongoc_init (); |
| 59 | + |
| 60 | + client = mongoc_client_new( |
| 61 | + "mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true" |
| 62 | + ); |
| 63 | + database = mongoc_client_get_database (client, "test"); |
| 64 | + |
| 65 | + mongoc_database_destroy (database); |
| 66 | + mongoc_client_destroy (client); |
| 67 | + |
| 68 | + mongoc_cleanup (); |
| 69 | + |
| 70 | + return 0; |
| 71 | + } |
| 72 | + |
| 73 | + |
| 74 | +See `Advanced Connections <http://mongoc.org/libmongoc/current/advanced-connections.html>`__ |
| 75 | +for more ways to connect. |
| 76 | + |
| 77 | + |
| 78 | +Compatibility |
| 79 | +------------- |
| 80 | + |
| 81 | +MongoDB Compatibility |
| 82 | +~~~~~~~~~~~~~~~~~~~~~ |
| 83 | + |
| 84 | +.. include:: /includes/extracts/c-driver-compatibility-matrix-mongodb.rst |
| 85 | + |
| 86 | +.. include:: /includes/mongodb-compatibility-table-c.rst |
| 87 | + |
| 88 | +.. include:: /includes/older-server-versions-unsupported.rst |
| 89 | + |
| 90 | +Language Compatibility |
| 91 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 92 | + |
| 93 | +.. include:: /includes/extracts/c-driver-compatibility-matrix-language.rst |
| 94 | + |
| 95 | +.. include:: /includes/language-compatibility-table-c.rst |
| 96 | + |
| 97 | + |
| 98 | +How to get help |
| 99 | +--------------- |
| 100 | + |
| 101 | +- Join our `Google Group <http://groups.google.com/group/mongodb-user>`__. |
| 102 | +- Ask on `Stack Overflow <http://stackoverflow.com/questions/tagged/mongodb-c>`__. |
| 103 | +- Visit our `Support Channels <http://www.mongodb.org/about/support>`__. |
| 104 | +- File a bug or feature request on `JIRA <https://jira.mongodb.org/browse/CDRIVER>`__. |
| 105 | + |
| 106 | + |
0 commit comments