1MONGOC_COLLECTION_WRITE_COMMAND_WITMHlO_iNObGPmOToCSn_(gC3oO)cLLECTION_WRITE_COMMAND_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_collection_write_command_with_opts        -       mongoc_collec‐
7       tion_write_command_with_opts()
8

SYNOPSIS

10          bool
11          mongoc_collection_write_command_with_opts (mongoc_collection_t *collection,
12                                                     const bson_t *command,
13                                                     const bson_t *opts,
14                                                     bson_t *reply,
15                                                     bson_error_t *error);
16
17       Execute a command on the server, applying logic  that  is  specific  to
18       commands  that  write,  and  taking the MongoDB server version into ac‐
19       count. To send a raw command to the server without any of  this  logic,
20       use mongoc_collection_command_simple.
21
22       Use  this  function  for commands that write such as "drop" or "create‐
23       Role" (but not for "insert", "update", or "delete", see Basic Write Op‐
24       erations).  Write  concern  and  collation can be overridden by various
25       sources. In a transaction, read concern and write concern  are  prohib‐
26       ited in opts. The highest-priority sources for these options are listed
27       first in the following table. The write concern is omitted for  MongoDB
28       before 3.4.
29
30                             ┌──────────────┬───────────┐
31                             │Write Concern │ Collation │
32                             ├──────────────┼───────────┤
33opts          opts      
34                             ├──────────────┼───────────┤
35                             │Transaction   │           │
36                             ├──────────────┼───────────┤
37collection    │           │
38                             └──────────────┴───────────┘
39
40       See  the  example  for transactions and for the "distinct" command with
41       opts.
42
43       reply is always initialized, and must be freed with bson_destroy().
44

PARAMETERS

46collection: A mongoc_collection_t.
47
48command: A bson_t containing the command specification.
49
50opts: A bson_t containing additional options.
51
52reply: A location for the resulting document.
53
54error: 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
58writeConcern:  Construct  a  mongoc_write_concern_t  and   use   mon‐
59         goc_write_concern_append  to  add  the write concern to opts. See the
60         example code for mongoc_client_write_command_with_opts.
61
62sessionId:  First,  construct  a  mongoc_client_session_t  with  mon‐
63         goc_client_start_session.  You  can  begin  a  transaction  with mon‐
64         goc_client_session_start_transaction, optionally with a mongoc_trans‐
65         action_opt_t  that  overrides  the options inherited from collection,
66         and use mongoc_client_session_append to add the session to opts.  See
67         the example code for mongoc_client_session_t.
68
69collation:  Configure  textual comparisons. See Setting Collation Or‐
70         der, and the MongoDB Manual entry on  Collation.  Collation  requires
71         MongoDB 3.2 or later, otherwise an error is returned.
72
73serverId:  To  target  a specific server, include an int32 "serverId"
74         field. Obtain the id  by  calling  mongoc_client_select_server,  then
75         mongoc_server_description_id on its return value.
76
77       Consult  the  MongoDB  Manual  entry on Database Commands for each com‐
78       mand's arguments.
79

ERRORS

81       Errors are propagated via the error parameter.
82

RETURNS

84       Returns true if successful. Returns false and sets error if  there  are
85       invalid arguments or a server or network error.
86
87       A write concern timeout or write concern error is considered a failure.
88

BASIC WRITE OPERATIONS

90       Do  not  use  this  function to call the basic write commands "insert",
91       "update", and "delete". Those commands require special logic not imple‐
92       mented  in  mongoc_collection_write_command_with_opts.  For basic write
93       operations use CRUD functions such as mongoc_collection_insert_one  and
94       the others described in the CRUD tutorial, or use the Bulk API.
95

EXAMPLE

97       See the example code for mongoc_client_read_command_with_opts.
98

AUTHOR

100       MongoDB, Inc
101
103       2017-present, MongoDB, Inc
104
105
106
107
1081.21.1                           MaMrON0G2O,C_2C0O2L2LECTION_WRITE_COMMAND_WITH_OPTS(3)
Impressum