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