MONGOC_COLLECTION_UPDATE(3)

✨ MONGOC_COLLECTION_UPDATE(3) ✨

okay bestie, welcome to the libmongoc page for MONGOC_COLLECTION_UPDATE(3) β€” this is the one where we go update some documents in a collection πŸ’… (manual section 3, in case the (3) was keeping you up at night 🫢)


🌸 SYNOPSIS 🌸

here's the whole signature, and yes you're gonna want to copy it exactly because it's long:

bool
mongoc_collection_update (mongoc_collection_t *collection,
                          mongoc_update_flags_t flags,
                          const bson_t *selector,
                          const bson_t *update,
                          const mongoc_write_concern_t *write_concern,
                          bson_error_t *error);

like, look at all those params. it's giving ✨thorough✨. she returns a bool, she takes six things, she's booked and busy.


πŸŽ€ PARAMETERS πŸŽ€

  • collection β€” a mongoc_collection_t. the collection. the main character. the place where the documents live πŸ’–
  • flags β€” a bitwise or of mongoc_update_flags_t. yes, bitwise or, so you can stack them up like friendship bracelets πŸ¦‹
  • selector β€” a bson_t containing the query to match documents for updating. this is the "who we're talking about" part, iykyk
  • update β€” a bson_t containing the update to perform. and heads up: if you're updating with a pipeline, this is a bson_t array instead πŸ”₯
  • write_concern β€” a mongoc_write_concern_t. the write concern. slay.
  • error β€” an optional location for a bson_error_t, or NULL. optional!! no pressure ✨

πŸ’œ DESCRIPTION πŸ’œ

NOTE: to pass additional options, use mongoc_collection_update_one(), mongoc_collection_update_many(), or mongoc_collection_replace_one(). like, if you need more, those three are your girls πŸ’…

this function shall update documents in collection that match selector. that's literally the whole gig, no cap.

by default, it only updates a single document. ok so the way this works: if you want to update multiple documents, set flags to MONGOC_UPDATE_MULTI_UPDATE. that's the switch. flip it. 🫢


😭 ERRORS 😭

errors are propagated via the error parameter. that's where they show up. that's the vibe.


🌈 RETURNS 🌈

returns true if successful ✨

returns false and sets error if there are invalid arguments, or a server error, or a network error. so basically false has receipts β€” it tells you what went wrong πŸ’€

and listen: a write concern timeout or write concern error is considered a failure. yes, even those. fr fr, don't assume it worked. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


and that's the page bestie, go forth and update responsibly πŸ§šπŸ’–

sign-off time: this iconic little page is from version 2.5.6, dated Oct 09, 2026 β€” and it's MONGOC_COLLECTION_UPDATE(3) all the way down. periodt. ⭐

πŸ“¦ where this page comes from