1MONGOC_CLIENT_GET_DATABASE_NAMES_WMIOTlNHiG_bOOmCPo_TnCSgL(oI3cE)NT_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 BSON_GNUC_WARN_UNUSED_RESULT;
15
16 This function queries the MongoDB server for a list of known databases.
17
19 • client: A mongoc_client_t.
20
21 • opts: A bson_t containing additional options.
22
23 • error: An optional location for a bson_error_t or NULL.
24
25 opts may be NULL or a BSON document with additional command options:
26
27 • sessionId: First, construct a mongoc_client_session_t with mon‐
28 goc_client_start_session. You can begin a transaction with mon‐
29 goc_client_session_start_transaction, optionally with a mongoc_trans‐
30 action_opt_t that overrides the options inherited from client, and
31 use mongoc_client_session_append to add the session to opts. See the
32 example code for mongoc_client_session_t.
33
34 • serverId: To target a specific server, include an int32 "serverId"
35 field. Obtain the id by calling mongoc_client_select_server, then
36 mongoc_server_description_id on its return value.
37
38 This function is considered a retryable read operation. Upon a tran‐
39 sient error (a network error, errors due to replica set failover, etc.)
40 the operation is safely retried once. If retryreads is false in the
41 URI (see mongoc_uri_t) the retry behavior does not apply.
42
44 Errors are propagated via the error parameter.
45
47 A NULL terminated vector of NULL-byte terminated strings. The result
48 should be freed with bson_strfreev().
49
50 NULL is returned upon failure and error is set.
51
53 {
54 bson_error_t error;
55 char **strv;
56 unsigned i;
57
58 if ((strv = mongoc_client_get_database_names_with_opts (client, NULL, &error))) {
59 for (i = 0; strv[i]; i++)
60 printf ("%s\n", strv[i]);
61 bson_strfreev (strv);
62 } else {
63 fprintf (stderr, "Command failed: %s\n", error.message);
64 }
65 }
66
68 MongoDB, Inc
69
71 2017-present, MongoDB, Inc
72
73
74
75
761.21.1 MMaOrNG0O2C,_C2L0I2E2NT_GET_DATABASE_NAMES_WITH_OPTS(3)