1MONGOC_DATABASE_READ_WRITE_COMMAMNODN_GWlOIiCTb_HmD_oAOnTPgAToBScA(S3E)_READ_WRITE_COMMAND_WITH_OPTS(3)
2
3
4
6 bool
7 mongoc_database_read_write_command_with_opts (
8 mongoc_database_t *database,
9 const bson_t *command,
10 const mongoc_read_prefs_t *read_prefs /* UNUSED */,
11 const bson_t *opts,
12 bson_t *reply,
13 bson_error_t *error);
14
15 Execute a command on the server, applying logic for commands that both
16 read and write, and taking the MongoDB server version into account. To
17 send a raw command to the server without any of this logic, use
18 mongoc_database_command_simple().
19
20 Use this function for commands that both read and write, such as
21 "mapReduce" with an output collection.
22
23 Read and write concern and collation can be overridden by various
24 sources. In a transaction, read concern and write concern are prohib‐
25 ited in opts. The highest-priority sources for these options are listed
26 first in the following table. Read preferences are not applied. The
27 write concern is omitted for MongoDB before 3.4.
28
29 ┌─────────────┬───────────────┬───────────┐
30 │Read Concern │ Write Concern │ Collation │
31 ├─────────────┼───────────────┼───────────┤
32 │opts │ opts │ opts │
33 ├─────────────┼───────────────┼───────────┤
34 │Transaction │ Transaction │ │
35 ├─────────────┼───────────────┼───────────┤
36 │database │ database │ │
37 └─────────────┴───────────────┴───────────┘
38
39 See the example for transactions and for the "distinct" command with
40 opts.
41
42 reply is always initialized, and must be freed with bson_destroy().
43
44 (The mongoc_read_prefs_t parameter was included by mistake when this
45 function was introduced in libmongoc 1.5. A command that writes must
46 not obey a read preference.)
47
49 • database: A mongoc_database_t.
50
51 • command: A bson_t containing the command specification.
52
53 • read_prefs: Ignored.
54
55 • opts: A bson_t containing additional options.
56
57 • reply: A location for the resulting document.
58
59 • error: An optional location for a bson_error_t or NULL.
60
61 opts may be NULL or a BSON document with additional command options:
62
63 • readConcern: Construct a mongoc_read_concern_t and use
64 mongoc_read_concern_append() to add the read concern to opts. See the
65 example code for mongoc_client_read_command_with_opts(). Read concern
66 requires MongoDB 3.2 or later, otherwise an error is returned.
67
68 • writeConcern: Construct a mongoc_write_concern_t and use
69 mongoc_write_concern_append() to add the write concern to opts. See
70 the example code for mongoc_client_write_command_with_opts().
71
72 • sessionId: First, construct a mongoc_client_session_t with
73 mongoc_client_start_session(). You can begin a transaction with
74 mongoc_client_session_start_transaction(), optionally with a
75 mongoc_transaction_opt_t that overrides the options inherited from
76 database, and use mongoc_client_session_append() to add the session
77 to opts. See the example code for mongoc_client_session_t.
78
79 • collation: Configure textual comparisons. See Setting Collation Or‐
80 der, and the MongoDB Manual entry on Collation. Collation requires
81 MongoDB 3.2 or later, otherwise an error is returned.
82
83 • serverId: To target a specific server, include an int32 "serverId"
84 field. Obtain the id by calling mongoc_client_select_server(), then
85 mongoc_server_description_id() on its return value.
86
87 Consult the MongoDB Manual entry on Database Commands for each com‐
88 mand's arguments.
89
91 Errors are propagated via the error parameter.
92
94 Returns true if successful. Returns false and sets error if there are
95 invalid arguments or a server or network error.
96
97 A write concern timeout or write concern error is considered a failure.
98
100 See the example code for mongoc_client_read_command_with_opts().
101
103 MongoDB, Inc
104
106 2017-present, MongoDB, Inc
107
108
109
110
1111.25.1 MONNoGvOC0_8D,AT2A0B2A3SE_READ_WRITE_COMMAND_WITH_OPTS(3)