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