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

SYNOPSIS

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

PARAMETERS

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

ERRORS

79       Errors are propagated via the error parameter.
80

RETURNS

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

BASIC WRITE OPERATIONS

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

EXAMPLE

95       See the example code for mongoc_client_read_command_with_opts().
96

AUTHOR

98       MongoDB, Inc
99
101       2017-present, MongoDB, Inc
102
103
104
105
1061.25.1                           NovM0O8N,GO2C0_2D3ATABASE_WRITE_COMMAND_WITH_OPTS(3)
Impressum