1MONGOC_COLLECTION_READ_WRITE_CMOOMNMGAONCDl__iCWbOImLToLHnE_gCOoTPcITOSN(_3R)EAD_WRITE_COMMAND_WITH_OPTS(3)
2
3
4

SYNOPSIS

6          bool
7          mongoc_collection_read_write_command_with_opts (
8             mongoc_collection_t *collection,
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_collection_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                     ├─────────────┼───────────────┼───────────┤
32opts         opts          opts      
33                     ├─────────────┼───────────────┼───────────┤
34                     │Transaction  │ Transaction   │           │
35                     ├─────────────┼───────────────┼───────────┤
36collection   collection    │           │
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

PARAMETERS

49collection: A mongoc_collection_t.
50
51command: A bson_t containing the command specification.
52
53read_prefs: Ignored.
54
55opts: A bson_t containing additional options.
56
57reply: A location for the resulting document.
58
59error: 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
63readConcern:    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
68writeConcern:    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
72sessionId:    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         collection, and use mongoc_client_session_append() to add the session
77         to opts. See the example code for mongoc_client_session_t.
78
79collation: 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
83serverId: 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

ERRORS

91       Errors are propagated via the error parameter.
92

RETURNS

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

EXAMPLE

100       See the example code for mongoc_client_read_command_with_opts().
101

AUTHOR

103       MongoDB, Inc
104
106       2017-present, MongoDB, Inc
107
108
109
110
1111.25.1                       MONGNOoCv_C0O8L,LE2C0T2I3ON_READ_WRITE_COMMAND_WITH_OPTS(3)
Impressum