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