1MONGOC_DATABASE_FIND_COLLECTIONS_WMIOTlNHiG_bOOmCPo_TnDSgA(oT3cA)BASE_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             BSON_GNUC_WARN_UNUSED_RESULT;
14
15       Fetches a cursor containing documents, each corresponding to a  collec‐
16       tion on this database.
17
18       To   get   collection   names   only,  use  mongoc_database_get_collec‐
19       tion_names_with_opts.
20
21       This function is considered a retryable read operation.  Upon  a  tran‐
22       sient error (a network error, errors due to replica set failover, etc.)
23       the operation is safely retried once.  If retryreads is  false  in  the
24       URI (see mongoc_uri_t) the retry behavior does not apply.
25

PARAMETERS

27database: A mongoc_database_t.
28
29opts: A bson_t containing additional options.
30
31       opts may be NULL or a BSON document with additional command options:
32
33sessionId:  First,  construct  a  mongoc_client_session_t  with  mon‐
34         goc_client_start_session. You  can  begin  a  transaction  with  mon‐
35         goc_client_session_start_transaction, optionally with a mongoc_trans‐
36         action_opt_t that overrides the options inherited from database,  and
37         use  mongoc_client_session_append to add the session to opts. See the
38         example code for mongoc_client_session_t.
39
40serverId: To target a specific server, include  an  int32  "serverId"
41         field.  Obtain  the  id  by calling mongoc_client_select_server, then
42         mongoc_server_description_id on its return value.
43
44       For a list of all options, see the MongoDB Manual entry on the listCol‐
45       lections command.
46

ERRORS

48       Use mongoc_cursor_error on the returned cursor to check for errors.
49

RETURNS

51       This  function returns a newly allocated mongoc_cursor_t that should be
52       freed with mongoc_cursor_destroy() when no longer in use. The  returned
53       mongoc_cursor_t  is  never NULL, even on error. The user must call mon‐
54       goc_cursor_next() on the returned mongoc_cursor_t to execute  the  ini‐
55       tial command.
56
57       Cursor  errors can be checked with mongoc_cursor_error_document. It al‐
58       ways fills out the bson_error_t if an error  occurred,  and  optionally
59       includes a server reply document if the error occurred server-side.
60
61       WARNING:
62          Failure  to  handle the result of this function is a programming er‐
63          ror.
64
65       In the returned cursor each result corresponds to the  server's  repre‐
66       sentation of a collection in this database.
67
68       The     cursor     functions    mongoc_cursor_set_limit,    mongoc_cur‐
69       sor_set_batch_size, and mongoc_cursor_set_max_await_time_ms have no use
70       on the returned cursor.
71

EXAMPLES

73          {
74             bson_t opts = BSON_INITIALIZER;
75             bson_t name_filter;
76             const bson_t *doc;
77             bson_iter_t iter;
78             bson_error_t error;
79
80             BSON_APPEND_DOCUMENT_BEGIN (&opts, "filter", &name_filter);
81             /* find collections with names like "abbbbc" */
82             BSON_APPEND_REGEX (&name_filter, "name", "ab+c", NULL);
83             bson_append_document_end (&opts, &name_filter);
84
85             cursor = mongoc_database_find_collections_with_opts (database, &opts);
86             while (mongoc_cursor_next (cursor, &doc)) {
87                bson_iter_init_find (&iter, doc, "name");
88                printf ("found collection: %s\n", bson_iter_utf8 (&iter, NULL));
89             }
90
91             if (mongoc_cursor_error (cursor, &error))
92                fprintf (stderr, "%s\n", error.msg);
93             }
94
95             mongoc_cursor_destroy (cursor);
96             bson_destroy (&opts);
97          }
98
99       SEE ALSO:
100          mongoc_database_get_collection_names_with_opts()
101
102

AUTHOR

104       MongoDB, Inc
105
107       2017-present, MongoDB, Inc
108
109
110
111
1121.20.0                           NMoOvNG1O8C,_D2A0T2A1BASE_FIND_COLLECTIONS_WITH_OPTS(3)
Impressum