1MONGOC_DATABASE_WRITE_COMMAND_WITH_OlPiMTbOSmN(oG3nO)gCo_cDATABASE_WRITE_COMMAND_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_database_write_command_with_opts   -  mongoc_database_write_com‐
7       mand_with_opts()
8

SYNOPSIS

10          bool
11          mongoc_database_write_command_with_opts (mongoc_database_t *database,
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_database_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                             ├──────────────┼───────────┤
37database      │           │
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

46database: A mongoc_database_t.
47
48db_name: The name of the database to run the command on.
49
50command: A bson_t containing the command specification.
51
52opts: A bson_t containing additional options.
53
54reply: A location for the resulting document.
55
56error: An optional location for a bson_error_t or NULL.
57
58       opts may be NULL or a BSON document with additional command options:
59
60writeConcern:   Construct   a    mongoc_write_concern_t    and    use
61         mongoc_write_concern_append()  to  add the write concern to opts. See
62         the example code for mongoc_client_write_command_with_opts().
63
64sessionId:   First,   construct   a   mongoc_client_session_t    with
65         mongoc_client_start_session().  You  can  begin  a  transaction  with
66         mongoc_client_session_start_transaction(),    optionally    with    a
67         mongoc_transaction_opt_t  that  overrides  the options inherited from
68         database, and use mongoc_client_session_append() to add  the  session
69         to opts. See the example code for mongoc_client_session_t.
70
71collation:  Configure  textual comparisons. See Setting Collation Or‐
72         der, and the MongoDB Manual entry on  Collation.  Collation  requires
73         MongoDB 3.2 or later, otherwise an error is returned.
74
75serverId:  To  target  a specific server, include an int32 "serverId"
76         field. Obtain the id by calling  mongoc_client_select_server(),  then
77         mongoc_server_description_id() on its return value.
78
79       Consult  the  MongoDB  Manual  entry on Database Commands for each com‐
80       mand's arguments.
81

ERRORS

83       Errors are propagated via the error parameter.
84

RETURNS

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

BASIC WRITE OPERATIONS

92       Do  not  use  this  function to call the basic write commands "insert",
93       "update", and "delete". Those commands require special logic not imple‐
94       mented  in mongoc_database_write_command_with_opts. For basic write op‐
95       erations use CRUD functions such as mongoc_collection_insert_one()  and
96       the others described in the CRUD tutorial, or use the Bulk API.
97

EXAMPLE

99       See the example code for mongoc_client_read_command_with_opts().
100

AUTHOR

102       MongoDB, Inc
103
105       2017-present, MongoDB, Inc
106
107
108
109
1101.24.3                           AugM1O7N,GO2C0_2D3ATABASE_WRITE_COMMAND_WITH_OPTS(3)
Impressum