1MONGOC_DATABASE_GET_COLLECTIONM_ONNAGMOECSl__iDWbAImTToAHnB_gAOoSPcET_SG(E3T)_COLLECTION_NAMES_WITH_OPTS(3)
2
3
4

SYNOPSIS

6          char **
7          mongoc_database_get_collection_names_with_opts (mongoc_database_t *database,
8                                                          const bson_t *opts,
9                                                          bson_error_t *error)
10             BSON_GNUC_WARN_UNUSED_RESULT;
11
12       Fetches  a  NULL terminated array of NULL-byte terminated char* strings
13       containing the names of all of the collections in database.
14
15       This function is considered a retryable read operation.  Upon  a  tran‐
16       sient error (a network error, errors due to replica set failover, etc.)
17       the operation is safely retried once.  If retryreads is  false  in  the
18       URI (see mongoc_uri_t) the retry behavior does not apply.
19

PARAMETERS

21database: A mongoc_database_t.
22
23opts: A bson_t containing additional options.
24
25error: An optional location for a bson_error_t or NULL.
26
27       opts may be NULL or a BSON document with additional command options:
28
29sessionId:    First,   construct   a   mongoc_client_session_t   with
30         mongoc_client_start_session().  You  can  begin  a  transaction  with
31         mongoc_client_session_start_transaction(),    optionally    with    a
32         mongoc_transaction_opt_t that overrides the  options  inherited  from
33         database,  and  use mongoc_client_session_append() to add the session
34         to opts. See the example code for mongoc_client_session_t.
35
36serverId: To target a specific server, include  an  int32  "serverId"
37         field.  Obtain  the id by calling mongoc_client_select_server(), then
38         mongoc_server_description_id() on its return value.
39
40       For a list of all options, see the MongoDB Manual entry on the listCol‐
41       lections command.
42

ERRORS

44       Errors are propagated via the error parameter.
45

RETURNS

47       A NULL terminated array of NULL terminated char* strings that should be
48       freed with bson_strfreev(). Upon failure, NULL is returned and error is
49       set.
50

EXAMPLES

52          {
53             bson_t opts = BSON_INITIALIZER;
54             mongoc_read_concern_t *rc;
55             bson_error_t error;
56             char **strv;
57             unsigned i;
58
59             rc = mongoc_read_concern_new ();
60             mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY);
61             mongoc_read_concern_append (rc, &opts);
62             if ((strv = mongoc_database_get_collection_names_with_opts (
63                    database, &opts, &error))) {
64
65                for (i = 0; strv[i]; i++)
66                   printf ("%s\n", strv[i]);
67
68                bson_strfreev (strv);
69             } else {
70                fprintf (stderr, "Command failed: %s\n", error.message);
71             }
72
73             mongoc_read_concern_destroy (rc);
74             bson_destroy (&opts);
75          }
76

AUTHOR

78       MongoDB, Inc
79
81       2017-present, MongoDB, Inc
82
83
84
85
861.25.1                       MONGNOoCv_D0A8T,AB2A0S2E3_GET_COLLECTION_NAMES_WITH_OPTS(3)
Impressum