1MONGOC_DATABASE_WRITE_COMMAND_WIMToHn_gOoPDMTBOSN(CG3O)DCr_iDvAeTrABASE_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
19       account. 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
24       Operations).  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

46       · database: A mongoc_database_t.
47
48       · db_name: The name of the database to run the command on.
49
50       · command: A bson_t containing the command specification.
51
52       · opts: A bson_t containing additional options.
53
54       · reply: A location for the resulting document.
55
56       · error: 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
60       · writeConcern:  Construct  a  mongoc_write_concern_t  and   use   mon‐
61         goc_write_concern_append  to  add  the write concern to opts. See the
62         example code for mongoc_client_write_command_with_opts.
63
64       · sessionId:  First,  construct  a  mongoc_client_session_t  with  mon‐
65         goc_client_start_session.  You  can  begin  a  transaction  with mon‐
66         goc_client_session_start_transaction, optionally with a mongoc_trans‐
67         action_opt_t  that overrides the options inherited from database, and
68         use mongoc_client_session_append to add the session to opts. See  the
69         example code for mongoc_client_session_t.
70
71       · collation:  Configure  textual  comparisons.  See  Setting  Collation
72         Order, and the MongoDB Manual entry on Collation. Collation  requires
73         MongoDB 3.2 or later, otherwise an error is returned.
74
75       · serverId:  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
95       operations 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.14.0                           FebM2O2N,GO2C0_1D9ATABASE_WRITE_COMMAND_WITH_OPTS(3)
Impressum