1MONGOC_CLIENT_GET_DATABASE_NAMESM_oWnMIgOToNHDG_BOOCPC_TCSDL(rI3iE)vNeTr_GET_DATABASE_NAMES_WITH_OPTS(3)
2
3
4
6 mongoc_client_get_database_names_with_opts - mongoc_client_get_data‐
7 base_names_with_opts()
8
10 char **
11 mongoc_client_get_database_names_with_opts (mongoc_client_t *client,
12 const bson_t *opts,
13 bson_error_t *error);
14
15 This function queries the MongoDB server for a list of known databases.
16
18 · client: A mongoc_client_t.
19
20 · opts: A bson_t containing additional options.
21
22 · error: An optional location for a bson_error_t or NULL.
23
24 opts may be NULL or a BSON document with additional command options:
25
26 · sessionId: First, construct a mongoc_client_session_t with mon‐
27 goc_client_start_session. You can begin a transaction with mon‐
28 goc_client_session_start_transaction, optionally with a mongoc_trans‐
29 action_opt_t that overrides the options inherited from client, and
30 use mongoc_client_session_append to add the session to opts. See the
31 example code for mongoc_client_session_t.
32
33 · serverId: To target a specific server, include an int32 "serverId"
34 field. Obtain the id by calling mongoc_client_select_server, then
35 mongoc_server_description_id on its return value.
36
38 Errors are propagated via the error parameter.
39
41 A NULL terminated vector of NULL-byte terminated strings. The result
42 should be freed with bson_strfreev().
43
44 NULL is returned upon failure and error is set.
45
47 {
48 bson_error_t error;
49 char **strv;
50 unsigned i;
51
52 if ((strv = mongoc_client_get_database_names_with_opts (client, NULL, &error))) {
53 for (i = 0; strv[i]; i++)
54 printf ("%s\n", strv[i]);
55 bson_strfreev (strv);
56 } else {
57 fprintf (stderr, "Command failed: %s\n", error.message);
58 }
59 }
60
62 MongoDB, Inc
63
65 2017-present, MongoDB, Inc
66
67
68
69
701.13.1 JMaOnNG2O4C,_C2L0I1E9NT_GET_DATABASE_NAMES_WITH_OPTS(3)