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

SYNOPSIS

6          bool
7          mongoc_collection_write_command_with_opts (mongoc_collection_t *collection,
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_collection_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                             ├──────────────┼───────────┤
33collection    │           │
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

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

ERRORS

77       Errors are propagated via the error parameter.
78

RETURNS

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

BASIC WRITE OPERATIONS

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

EXAMPLE

93       See the example code for mongoc_client_read_command_with_opts().
94

AUTHOR

96       MongoDB, Inc
97
99       2017-present, MongoDB, Inc
100
101
102
103
1041.25.1                           NoMvON0G8O,C_2C0O2L3LECTION_WRITE_COMMAND_WITH_OPTS(3)
Impressum