1MONGOC_DATABASE_FIND_COLLECTIONSM_oWnMIgOToNHDG_BOOCPC_TDSDA(rT3iA)vBeArSE_FIND_COLLECTIONS_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_database_find_collections_with_opts  - mongoc_database_find_col‐
7       lections_with_opts()
8

SYNOPSIS

10          mongoc_cursor_t *
11          mongoc_database_find_collections_with_opts (mongoc_database_t *database,
12                                                      const bson_t *opts);
13
14       Fetches a cursor containing documents, each corresponding to a  collec‐
15       tion on this database.
16
17       To   get   collection   names   only,  use  mongoc_database_get_collec‐
18       tion_names_with_opts.
19

PARAMETERS

21       · database: A mongoc_database_t.
22
23       · opts: A bson_t containing additional options.
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       Use mongoc_cursor_error on the returned cursor to check for errors.
43

RETURNS

45       A cursor where each result corresponds to the  server's  representation
46       of a collection in this database.
47
48       The     cursor     functions    mongoc_cursor_set_limit,    mongoc_cur‐
49       sor_set_batch_size, and mongoc_cursor_set_max_await_time_ms have no use
50       on the returned cursor.
51

EXAMPLES

53          {
54             bson_t opts = BSON_INITIALIZER;
55             bson_t name_filter;
56             const bson_t *doc;
57             bson_iter_t iter;
58             bson_error_t error;
59
60             BSON_APPEND_DOCUMENT_BEGIN (&opts, "filter", &name_filter);
61             /* find collections with names like "abbbbc" */
62             BSON_APPEND_REGEX (&name_filter, "name", "ab+c", NULL);
63             bson_append_document_end (&opts, &name_filter);
64
65             cursor = mongoc_database_find_collections_with_opts (database, &opts);
66             while (mongoc_cursor_next (cursor, &doc)) {
67                bson_iter_init_find (&iter, doc, "name");
68                printf ("found collection: %s\n", bson_iter_utf8 (&iter, NULL));
69             }
70
71             if (mongoc_cursor_error (cursor, &error))
72                fprintf (stderr, "%s\n", error.msg);
73             }
74
75             mongoc_cursor_destroy (cursor);
76             bson_destroy (&opts);
77          }
78

SEE ALSO

80       mongoc_database_get_collection_names_with_opts()
81

AUTHOR

83       MongoDB, Inc
84
86       2017-present, MongoDB, Inc
87
88
89
90
911.13.1                           JMaOnNG2O4C,_D2A0T1A9BASE_FIND_COLLECTIONS_WITH_OPTS(3)
Impressum