-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection.c
44 lines (41 loc) · 1.26 KB
/
connection.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//This is basic boilerplate code for connecting mongodb to C.
// This is basically a version of mongoose but for C. If that makes sense.
// #include <mongoc/mongoc.h>
// int
// main (int argc, char *argv[])
// {
// mongoc_database_t *database;
// mongoc_client_t *client;
// mongoc_init ();
// // Replace the uri string with your MongoDB deployment's connection string.
// client = mongoc_client_new(
// "mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority"
// );
// database = mongoc_client_get_database (client, "test");
// mongoc_database_destroy (database);
// mongoc_client_destroy (client);
// mongoc_cleanup ();
// return 0;
// }
#include <mongoc/mongoc.h>
int main (int argc, char *argv[])
{
mongoc_database_t *database;
mongoc_client_t *client;
mongoc_init ();
// Replace the uri string with your MongoDB deployment's connection string.
client = mongoc_client_new(
"mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority"
);
database = mongoc_client_get_database (client, "test");
mongoc_database_destroy (database);
mongoc_client_destroy (client);
mongoc_cleanup ();
return 0;
}
// Itiaffy
// Itiaffy
// Itiaffy
// Itiaffy
// Itiaffy
// Itiaffy