Skip to content

Commit c5d98ff

Browse files
committed
Rollback changes
1 parent 56bfe6d commit c5d98ff

File tree

190 files changed

+14156
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+14156
-123
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

REVIEWING.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

snooty.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ api-is-experimental = "This API {+is-experimental+}"
3131
opt-is-experimental = "This option {+is-experimental+}"
3232
api-libbson = "https://mongoc.org/libbson/current"
3333
api-libmongoc = "https://mongoc.org/libmongoc/current"
34-
driver-long = "MongoDB C Driver"
35-
driver-short = "C driver"
36-
language = "C"
37-
mdb-server = "MongoDB Server"
38-
stable-api = "Stable API"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <mongoc/mongoc.h>
2+
3+
int main(void) {
4+
mongoc_client_t *client = NULL;
5+
bson_error_t error = {0};
6+
mongoc_database_t *database = NULL;
7+
bson_t *command = NULL;
8+
bson_t reply = BSON_INITIALIZER;
9+
int rc = 0;
10+
bool ok = true;
11+
12+
// Initialize the MongoDB C Driver.
13+
mongoc_init();
14+
15+
client = mongoc_client_new("<connection string>");
16+
if (!client) {
17+
fprintf(stderr, "Failed to create a MongoDB client.\n");
18+
rc = 1;
19+
goto cleanup;
20+
}
21+
22+
// Get a handle on the "admin" database.
23+
database = mongoc_client_get_database(client, "admin");
24+
if (!database) {
25+
fprintf(stderr, "Failed to get a MongoDB database handle.\n");
26+
rc = 1;
27+
goto cleanup;
28+
}
29+
30+
// Ping the database.
31+
command = BCON_NEW("ping", BCON_INT32(1));
32+
ok = mongoc_database_command_simple(
33+
database, command, NULL, &reply, &error
34+
);
35+
if (!ok) {
36+
fprintf(stderr, "error: %s\n", error.message);
37+
rc = 1;
38+
goto cleanup;
39+
}
40+
bson_destroy(&reply);
41+
42+
printf("Pinged your deployment. You successfully connected to MongoDB!\n");
43+
44+
// Perform cleanup.
45+
cleanup:
46+
bson_destroy(command);
47+
mongoc_database_destroy(database);
48+
mongoc_client_destroy(client);
49+
mongoc_cleanup();
50+
51+
return rc;
52+
}

source/includes/c-connection.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <mongoc/mongoc.h>
2+
3+
int main(void) {
4+
mongoc_client_t *client = NULL;
5+
bson_error_t error = {0};
6+
mongoc_server_api_t *api = NULL;
7+
mongoc_database_t *database = NULL;
8+
bson_t *command = NULL;
9+
bson_t reply = BSON_INITIALIZER;
10+
int rc = 0;
11+
bool ok = true;
12+
13+
// Initialize the MongoDB C Driver.
14+
mongoc_init();
15+
16+
client = mongoc_client_new("<connection string>");
17+
if (!client) {
18+
fprintf(stderr, "Failed to create a MongoDB client.\n");
19+
rc = 1;
20+
goto cleanup;
21+
}
22+
23+
// Set the version of the Stable API on the client.
24+
api = mongoc_server_api_new(MONGOC_SERVER_API_V1);
25+
if (!api) {
26+
fprintf(stderr, "Failed to create a MongoDB server API.\n");
27+
rc = 1;
28+
goto cleanup;
29+
}
30+
31+
ok = mongoc_client_set_server_api(client, api, &error);
32+
if (!ok) {
33+
fprintf(stderr, "error: %s\n", error.message);
34+
rc = 1;
35+
goto cleanup;
36+
}
37+
38+
// Get a handle on the "admin" database.
39+
database = mongoc_client_get_database(client, "admin");
40+
if (!database) {
41+
fprintf(stderr, "Failed to get a MongoDB database handle.\n");
42+
rc = 1;
43+
goto cleanup;
44+
}
45+
46+
// Ping the database.
47+
command = BCON_NEW("ping", BCON_INT32(1));
48+
ok = mongoc_database_command_simple(
49+
database, command, NULL, &reply, &error
50+
);
51+
if (!ok) {
52+
fprintf(stderr, "error: %s\n", error.message);
53+
rc = 1;
54+
goto cleanup;
55+
}
56+
bson_destroy(&reply);
57+
58+
printf("Pinged your deployment. You successfully connected to MongoDB!\n");
59+
60+
// Perform cleanup.
61+
cleanup:
62+
bson_destroy(command);
63+
mongoc_database_destroy(database);
64+
mongoc_server_api_destroy(api);
65+
mongoc_client_destroy(client);
66+
mongoc_cleanup();
67+
68+
return rc;
69+
}

source/index.txt

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,118 @@
1+
.. _index:
2+
13
================
2-
{+driver-long+}
4+
MongoDB C Driver
35
================
46

7+
.. facet::
8+
:name: programming_language
9+
:values: c
10+
11+
.. facet::
12+
:name: genre
13+
:values: reference
14+
15+
.. meta::
16+
:keywords: code example, get started, sample app
17+
18+
.. contents:: On this page
19+
:local:
20+
:backlinks: none
21+
:depth: 1
22+
:class: twocols
23+
524
.. toctree::
625
:titlesonly:
726
:maxdepth: 1
827

9-
libbson API Documentation <{+api-libbson+}>
10-
libmongoc API Documentation <{+api-libmongoc+}>
28+
/libbson
29+
/libmongoc
1130

1231
Introduction
1332
------------
1433

15-
Welcome to the documentation site for the {+driver-long+}, also known as **libmongoc**,
16-
the official MongoDB driver for {+language+} applications.
34+
Welcome to the documentation site for the official MongoDB C driver.
35+
You can add the driver to your application to work with MongoDB in C.
36+
Download the required libraries, ``libmongoc`` and ``libbson``, by following
37+
the :ref:`obtaining_libraries` instructions or set up a runnable project by
38+
following our tutorial.
39+
40+
- :ref:`Tutorial <mongoc_tutorial>`
1741

18-
.. TODO: Uncomment when BSON guide is created
19-
.. ``libmongoc`` depends on the ``libbson`` library. To learn more about ``libbson``, see
20-
.. <BSON guide link>.
42+
- :ref:`Usage Guide <libmongoc>`
2143

22-
.. TODO
23-
.. Get Started
24-
.. -----------
44+
- `MongoDB Developer Center <https://www.mongodb.com/developer/languages/c/>`__
2545

26-
.. Learn how to install the driver, establish a connection to MongoDB, and begin
27-
.. working with data in the :ref:`c-get-started` tutorial.
46+
- `API Reference <https://mongoc.org/libmongoc/current/api.html>`_
2847

29-
.. TODO
30-
.. Connect to MongoDB
31-
.. ------------------
48+
- `Changelog <https://github.com/mongodb/mongo-c-driver/releases>`__
3249

33-
.. Learn how to create and configure a connection to a MongoDB deployment
34-
.. in the :ref:`c-connect` section.
50+
- `Source Code <https://github.com/mongodb/mongo-c-driver>`__
3551

36-
.. TODO
37-
.. What's New
38-
.. ----------
52+
- `Examples <https://github.com/mongodb/mongo-c-driver/tree/master/src/libmongoc/examples>`__
3953

40-
.. For a list of new features and changes in each version, see the :ref:`What's New <c-whats-new>`
41-
.. section.
54+
- `Additional BSON Examples <https://github.com/mongodb/mongo-c-driver/tree/master/src/libbson/examples>`__
4255

43-
.. TODO
44-
.. Write Data to MongoDB
45-
.. ---------------------
56+
Connect to MongoDB Atlas
57+
------------------------
4658

47-
.. Learn how you can write data to MongoDB in the :ref:`c-write` section.
59+
You can use the following connection snippet to test your connection to your
60+
MongoDB deployment on Atlas:
4861

49-
.. TODO
50-
.. Read Data from MongoDB
51-
.. ----------------------
62+
.. literalinclude:: /includes/c-connection.c
63+
:language: c
5264

53-
.. Learn how you can retrieve data from MongoDB in the :ref:`c-read` section.
65+
This connection snippet uses the Stable API feature. You can access this feature
66+
when connecting to MongoDB Server v5.0 and later and using the C driver v1.18 and later.
5467

55-
.. TODO
56-
.. Optimize Queries with Indexes
57-
.. -----------------------------
68+
When you use this feature, you can update your driver or server without
69+
worrying about backward compatibility issues with any commands covered by the
70+
Stable API.
5871

59-
.. Learn how to work with common types of indexes in the :ref:`c-indexes`
60-
.. section.
72+
.. note::
6173

62-
.. TODO
63-
.. Transform Your Data with Aggregation
64-
.. ------------------------------------
74+
Starting from February 2022, the **Versioned API** is known as the **Stable API**.
75+
All concepts and features remain the same with this naming change.
6576

66-
.. Learn how to use the {+driver-short+} to perform aggregation operations in the
67-
.. :ref:`c-aggregation` section.
77+
.. _connect-atlas-no-stable-api-c-driver:
6878

69-
.. Learn how to use aggregation expression operations to build
70-
.. aggregation stages in the :ref:`c-aggregation-expression-operations` section.
79+
Connect to MongoDB Atlas Without the Stable API
80+
-----------------------------------------------
7181

82+
If you are using a version of MongoDB or the driver that lacks support for the
83+
Stable API, you can use the following code snippet to test your connection
84+
to your MongoDB deployment on Atlas:
7285

73-
.. TODO:
74-
.. FAQ
75-
.. ---
86+
.. literalinclude:: /includes/c-connection-no-stable-api.c
87+
:language: c
7688

77-
.. For answers to commonly asked questions about the {+driver-short+}, see the
78-
.. :ref:`FAQ <c-faq>` section.
89+
Compatibility
90+
-------------
7991

80-
.. TODO
81-
.. Connection Troubleshooting
82-
.. --------------------------
92+
MongoDB Compatibility
93+
~~~~~~~~~~~~~~~~~~~~~
8394

84-
.. For solutions to some issues you might experience when connecting to a MongoDB
85-
.. deployment while using the {+driver-short+}, see the
86-
.. :ref:`Connection Troubleshooting <c-connection-troubleshooting>` section.
95+
The compatibility table in this section specifies the recommended version or
96+
versions of the MongoDB C driver for use with a specific version of MongoDB.
8797

88-
.. TODO
89-
.. Issues & Help
90-
.. -------------
98+
The first column lists the driver version.
9199

92-
.. Learn how to report bugs, contribute to the driver, and find more resources for
93-
.. asking questions and receiving help in the :ref:`Issues & Help <c-issues-and-help>` section.
100+
.. sharedinclude:: dbx/lifecycle-schedule-callout.rst
94101

95-
.. TODO
96-
.. Compatibility
97-
.. -------------
102+
.. include:: /libmongoc/includes/mongodb-compatibility-table-c.rst
98103

99-
.. For the compatibility charts that show the recommended {+driver-short+} version for each
100-
.. {+mdb-server+} version, see the :ref:`Compatibility <c-compatibility>` section.
104+
.. include:: /libmongoc/includes/older-server-versions-unsupported.rst
101105

102-
Learn
103-
------
106+
Language Compatibility
107+
~~~~~~~~~~~~~~~~~~~~~~
104108

105-
Visit the Developer Hub to learn more about the {+driver-long+}.
109+
The following compatibility table specifies the recommended version(s) of the
110+
MongoDB C driver for use with a specific version of C.
106111

107-
Developer Hub
108-
~~~~~~~~~~~~~
112+
The first column lists the driver version(s).
109113

110-
The Developer Hub provides tutorials and social engagement for
111-
developers.
114+
.. include:: /libmongoc/includes/language-compatibility-table-c.rst
112115

113-
To learn how to use MongoDB features with the {+driver-short+}, see the
114-
`How-Tos and Articles page <https://www.mongodb.com/developer/languages/c/>`__.
116+
.. include:: /libmongoc/includes/about-driver-compatibility.rst
115117

116-
To ask questions and engage in discussions with fellow developers who
117-
use the {+driver-short+}, see the `forums page <https://www.mongodb.com/community/forums/tag/c-driver>`__.
118+
.. include:: /libmongoc/includes/help-links-c.rst

0 commit comments

Comments
 (0)