1MONGOC_DATABASE_GET_COLLECTIONM_ONMNAoGMnOEgCSo__DDWBAITTCAHB_DAOrSPiETv_SeG(rE3T)_COLLECTION_NAMES_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_database_get_collection_names_with_opts      -      mongoc_data‐
7       base_get_collection_names_with_opts()
8

SYNOPSIS

10          char **
11          mongoc_database_get_collection_names_with_opts (mongoc_database_t *database,
12                                                          const bson_t *opts,
13                                                          bson_error_t *error);
14
15       Fetches a NULL terminated array of NULL-byte terminated  char*  strings
16       containing the names of all of the collections in database.
17

PARAMETERS

19       · database: A mongoc_database_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 database,  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       For a list of all options, see the MongoDB Manual entry on the listCol‐
39       lections command.
40

ERRORS

42       Errors are propagated via the error parameter.
43

RETURNS

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

EXAMPLES

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

AUTHOR

76       MongoDB, Inc
77
79       2017-present, MongoDB, Inc
80
81
82
83
841.14.0                       MONGFOeCb_D2A2T,AB2A0S1E9_GET_COLLECTION_NAMES_WITH_OPTS(3)
Impressum