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