1MONGOC_COLLECTION_REPLACE_ONE(3)   libmongoc  MONGOC_COLLECTION_REPLACE_ONE(3)
2
3
4

SYNOPSIS

6          bool
7          mongoc_collection_replace_one (mongoc_collection_t *collection,
8                                         const bson_t *selector,
9                                         const bson_t *replacement,
10                                         const bson_t *opts,
11                                         bson_t *reply,
12                                         bson_error_t *error);
13

PARAMETERS

15collection: A mongoc_collection_t.
16
17selector: A bson_t containing the query to match the document for up‐
18         dating.
19
20replacement: A bson_t containing the replacement document.
21
22reply: Optional. An uninitialized bson_t populated  with  the  update
23         result, or NULL.
24
25error: An optional location for a bson_error_t or NULL.
26
27       opts may be NULL or a BSON document with additional command options:
28
29writeConcern:    Construct    a    mongoc_write_concern_t   and   use
30         mongoc_write_concern_append() to add the write concern to  opts.  See
31         the example code for mongoc_client_write_command_with_opts().
32
33sessionId:    First,   construct   a   mongoc_client_session_t   with
34         mongoc_client_start_session().  You  can  begin  a  transaction  with
35         mongoc_client_session_start_transaction(),    optionally    with    a
36         mongoc_transaction_opt_t that overrides the  options  inherited  from
37         collection, and use mongoc_client_session_append() to add the session
38         to opts. See the example code for mongoc_client_session_t.
39
40validate:    Construct    a     bitwise-or     of     all     desired
41         bson_validate_flags_t. Set to false to skip client-side validation of
42         the provided BSON documents.
43
44comment: A bson_value_t specifying the comment to attach to this com‐
45         mand.  The  comment will appear in log messages, profiler output, and
46         currentOp output. Requires MongoDB 4.4 or later.
47
48bypassDocumentValidation: Set to true to skip server-side schema val‐
49         idation of the provided BSON documents.
50
51collation:  Configure  textual comparisons. See Setting Collation Or‐
52         der, and the MongoDB Manual entry on  Collation.  Collation  requires
53         MongoDB 3.2 or later, otherwise an error is returned.
54
55hint: A document or string that specifies the index to use to support
56         the query predicate.
57
58upsert: When true, creates a new document if no document matches  the
59         query.
60
61let:  A  BSON  document  consisting of any number of parameter names,
62         each followed by definitions of constants in the  MQL  Aggregate  Ex‐
63         pression language.
64

DESCRIPTION

66       This function shall replace documents in collection that match selector
67       with replacement.
68
69       If provided, reply will be initialized and populated  with  the  fields
70       matchedCount,  modifiedCount,  upsertedCount, and optionally upsertedId
71       if applicable. If there is a server error then reply contains either  a
72       writeErrors  array  with one subdocument or a writeConcernErrors array.
73       The reply must be freed with bson_destroy().
74

ERRORS

76       Errors are propagated via the error parameter.
77

RETURNS

79       Returns true if successful. Returns false and sets error if  there  are
80       invalid arguments or a server or network error.
81
82       A write concern timeout or write concern error is considered a failure.
83
84       SEE ALSO:
85          MongoDB update command documentation for more information on the update options.
86
87          mongoc_collection_update_one()
88
89          mongoc_collection_update_many()
90
91

AUTHOR

93       MongoDB, Inc
94
96       2017-present, MongoDB, Inc
97
98
99
100
1011.25.1                           Nov 08, 2023 MONGOC_COLLECTION_REPLACE_ONE(3)
Impressum