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

NAME

6       mongoc_collection_replace_one - mongoc_collection_replace_one()
7

SYNOPSIS

9          bool
10          mongoc_collection_replace_one (mongoc_collection_t *collection,
11                                         const bson_t *selector,
12                                         const bson_t *replacement,
13                                         const bson_t *opts,
14                                         bson_t *reply,
15                                         bson_error_t *error);
16

PARAMETERS

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

DESCRIPTION

69       This function shall replace documents in collection that match selector
70       with replacement.
71
72       If provided, reply will be initialized and populated  with  the  fields
73       matchedCount,  modifiedCount,  upsertedCount, and optionally upsertedId
74       if applicable. If there is a server error then reply contains either  a
75       writeErrors  array  with one subdocument or a writeConcernErrors array.
76       The reply must be freed with bson_destroy().
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
87       SEE ALSO:
88          MongoDB update command documentation for more information on the update options.
89
90          mongoc_collection_update_one()
91
92          mongoc_collection_update_many()
93
94

AUTHOR

96       MongoDB, Inc
97
99       2017-present, MongoDB, Inc
100
101
102
103
1041.24.3                           Aug 17, 2023 MONGOC_COLLECTION_REPLACE_ONE(3)
Impressum