1MONGOC_DATABASE_COMMAND(3) libmongoc MONGOC_DATABASE_COMMAND(3)
2
3
4
6 mongoc_cursor_t *
7 mongoc_database_command (mongoc_database_t *database,
8 mongoc_query_flags_t flags,
9 uint32_t skip,
10 uint32_t limit,
11 uint32_t batch_size,
12 const bson_t *command,
13 const bson_t *fields,
14 const mongoc_read_prefs_t *read_prefs)
15 BSON_GNUC_WARN_UNUSED_RESULT;
16
17 This function is superseded by mongoc_database_command_with_opts(),
18 mongoc_database_read_command_with_opts(),
19 mongoc_database_write_command_with_opts(), and
20 mongoc_database_read_write_command_with_opts().
21
23 This function creates a cursor which will execute the command when
24 mongoc_cursor_next() is called on it. The database's read preference,
25 read concern, and write concern are not applied to the command, and
26 mongoc_cursor_next() will not check the server response for a write
27 concern error or write concern timeout.
28
29 This function is not considered a retryable read operation.
30
32 • database: A mongoc_database_t.
33
34 • flags: A mongoc_query_flags_t.
35
36 • skip: The number of documents to skip on the server.
37
38 • limit: The maximum number of documents to return from the cursor.
39
40 • batch_size: Attempt to batch results from the server in groups of
41 batch_size documents.
42
43 • command: A bson_t containing the command.
44
45 • fields: An optional bson_t containing the fields to return. NULL for
46 all fields.
47
48 • read_prefs: An optional mongoc_read_prefs_t. Otherwise, the command
49 uses mode MONGOC_READ_PRIMARY.
50
52 This function returns a newly allocated mongoc_cursor_t that should be
53 freed with mongoc_cursor_destroy() when no longer in use. The returned
54 mongoc_cursor_t is never NULL, even on error. The user must call
55 mongoc_cursor_next() on the returned mongoc_cursor_t to execute the
56 initial command.
57
58 Cursor errors can be checked with mongoc_cursor_error_document(). It
59 always fills out the bson_error_t if an error occurred, and optionally
60 includes a server reply document if the error occurred server-side.
61
62 WARNING:
63 Failure to handle the result of this function is a programming er‐
64 ror.
65
67 MongoDB, Inc
68
70 2017-present, MongoDB, Inc
71
72
73
74
751.25.1 Nov 08, 2023 MONGOC_DATABASE_COMMAND(3)