1MONGOC_DATABASE_COMMAND_WITH_OPTS(3)libmongoMcONGOC_DATABASE_COMMAND_WITH_OPTS(3)
2
3
4
6 mongoc_database_command_with_opts - mongoc_database_command_with_opts()
7
9 bool
10 mongoc_database_command_with_opts (
11 mongoc_database_t *database,
12 const bson_t *command,
13 const mongoc_read_prefs_t *read_prefs,
14 const bson_t *opts,
15 bson_t *reply,
16 bson_error_t *error);
17
18 Execute a command on the server, interpreting opts according to the
19 MongoDB server version. To send a raw command to the server without any
20 of this logic, use mongoc_client_command_simple().
21
22 Read preferences, read and write concern, and collation can be overrid‐
23 den by various sources. The highest-priority sources for these options
24 are listed first:
25
26 ┌─────────────────┬──────────────┬───────────────┬───────────┐
27 │Read Preferences │ Read Concern │ Write Concern │ Collation │
28 ├─────────────────┼──────────────┼───────────────┼───────────┤
29 │read_prefs │ opts │ opts │ opts │
30 ├─────────────────┼──────────────┼───────────────┼───────────┤
31 │Transaction │ Transaction │ Transaction │ │
32 └─────────────────┴──────────────┴───────────────┴───────────┘
33
34 In a transaction, read concern and write concern are prohibited in opts
35 and the read preference must be primary or NULL. See the example for
36 transactions and for the "distinct" command with opts.
37
38 reply is always initialized, and must be freed with bson_destroy().
39
40 This function is not considered a retryable read operation.
41
43 • database: A mongoc_database_t.
44
45 • command: A bson_t containing the command specification.
46
47 • read_prefs: An optional mongoc_read_prefs_t.
48
49 • opts: A bson_t containing additional options.
50
51 • reply: A location for the resulting document.
52
53 • error: An optional location for a bson_error_t or NULL.
54
55 opts may be NULL or a BSON document with additional command options:
56
57 • readConcern: Construct a mongoc_read_concern_t and use
58 mongoc_read_concern_append() to add the read concern to opts. See the
59 example code for mongoc_client_read_command_with_opts(). Read concern
60 requires MongoDB 3.2 or later, otherwise an error is returned.
61
62 • writeConcern: Construct a mongoc_write_concern_t and use
63 mongoc_write_concern_append() to add the write concern to opts. See
64 the example code for mongoc_client_write_command_with_opts().
65
66 • sessionId: First, construct a mongoc_client_session_t with
67 mongoc_client_start_session(). You can begin a transaction with
68 mongoc_client_session_start_transaction(), optionally with a
69 mongoc_transaction_opt_t that overrides the options inherited from
70 database, and use mongoc_client_session_append() to add the session
71 to opts. See the example code for mongoc_client_session_t.
72
73 • collation: Configure textual comparisons. See Setting Collation Or‐
74 der, and the MongoDB Manual entry on Collation. Collation requires
75 MongoDB 3.2 or later, otherwise an error is returned.
76
77 • serverId: To target a specific server, include an int32 "serverId"
78 field. Obtain the id by calling mongoc_client_select_server(), then
79 mongoc_server_description_id() on its return value.
80
81 Consult the MongoDB Manual entry on Database Commands for each com‐
82 mand's arguments.
83
85 Errors are propagated via the error parameter.
86
88 Returns true if successful. Returns false and sets error if there are
89 invalid arguments or a server or network error.
90
91 The reply is not parsed for a write concern timeout or write concern
92 error.
93
95 See the example code for mongoc_client_read_command_with_opts().
96
98 MongoDB, Inc
99
101 2017-present, MongoDB, Inc
102
103
104
105
1061.24.3 Aug 17, 20M2O3NGOC_DATABASE_COMMAND_WITH_OPTS(3)