1MONGOC_COLLECTION_UPDATE_MANY(3) libmongoc MONGOC_COLLECTION_UPDATE_MANY(3)
2
3
4
6 bool
7 mongoc_collection_update_many (mongoc_collection_t *collection,
8 const bson_t *selector,
9 const bson_t *update,
10 const bson_t *opts,
11 bson_t *reply,
12 bson_error_t *error);
13
15 • collection: A mongoc_collection_t.
16
17 • selector: A bson_t containing the query to match documents for updat‐
18 ing.
19
20 • update: A bson_t containing the update to perform. If updating with a
21 pipeline, a bson_t array.
22
23 • reply: Optional. An uninitialized bson_t populated with the update
24 result, or NULL.
25
26 • error: An optional location for a bson_error_t or NULL.
27
28 opts may be NULL or a BSON document with additional command options:
29
30 • writeConcern: Construct a mongoc_write_concern_t and use
31 mongoc_write_concern_append() to add the write concern to opts. See
32 the example code for mongoc_client_write_command_with_opts().
33
34 • sessionId: First, construct a mongoc_client_session_t with
35 mongoc_client_start_session(). You can begin a transaction with
36 mongoc_client_session_start_transaction(), optionally with a
37 mongoc_transaction_opt_t that overrides the options inherited from
38 collection, and use mongoc_client_session_append() to add the session
39 to opts. See the example code for mongoc_client_session_t.
40
41 • validate: Construct a bitwise-or of all desired
42 bson_validate_flags_t. Set to false to skip client-side validation of
43 the provided BSON documents.
44
45 • comment: A bson_value_t specifying the comment to attach to this com‐
46 mand. The comment will appear in log messages, profiler output, and
47 currentOp output. Requires MongoDB 4.4 or later.
48
49 • bypassDocumentValidation: Set to true to skip server-side schema val‐
50 idation of the provided BSON documents.
51
52 • collation: Configure textual comparisons. See Setting Collation Or‐
53 der, and the MongoDB Manual entry on Collation. Collation requires
54 MongoDB 3.2 or later, otherwise an error is returned.
55
56 • hint: A document or string that specifies the index to use to support
57 the query predicate.
58
59 • upsert: When true, creates a new document if no document matches the
60 query.
61
62 • let: A BSON document consisting of any number of parameter names,
63 each followed by definitions of constants in the MQL Aggregate Ex‐
64 pression language.
65
66 • arrayFilters: An array of filters specifying to which array elements
67 an update should apply.
68
70 This function updates all documents in collection that match selector.
71
72 To update at most one document see mongoc_collection_update_one().
73
74 If you pass a non-NULL reply, it is filled out with fields matched‐
75 Count, modifiedCount, and optionally upsertedId if applicable. If there
76 is a server error then reply contains either a "writeErrors" array with
77 one subdocument or a "writeConcernErrors" array. The reply must be
78 freed with bson_destroy().
79
81 Errors are propagated via the error parameter.
82
84 Returns true if successful. Returns false and sets error if there are
85 invalid arguments or a server or network error.
86
87 A write concern timeout or write concern error is considered a failure.
88
89 SEE ALSO:
90 MongoDB update command documentation for more information on the update options.
91
92 mongoc_collection_update_one()
93
94
96 MongoDB, Inc
97
99 2017-present, MongoDB, Inc
100
101
102
103
1041.25.1 Nov 08, 2023 MONGOC_COLLECTION_UPDATE_MANY(3)