MONGOC_BULK_OP..._ONE_WITH_OPTS(3)

πŸ’… MONGOC_BULK_OP..._ONE_WITH_OPTS(3) β€” like, the libmongoc manual, bestie ✨

okay so real talk, this page is from the libmongoc manual and it's all about queuing one single update inside a bulk operation. no cap, it's more iconic than it sounds. let's get into it πŸŽ€


✨ SYNOPSIS ✨

bool
mongoc_bulk_operation_update_one_with_opts (mongoc_bulk_operation_t *bulk,
                                            const bson_t *selector,
                                            const bson_t *document,
                                            const bson_t *opts,
                                            bson_error_t *error); /* OUT */

So this function queues an update as part of a bulk operation. Key word: queues. It only ever modifies a single document on the MongoDB server β€” one and done, main character energy πŸ‘‘.

Like, it does not execute anything. nope. it just gets it ready. When you actually want the whole bulk operation to go brrr, you call mongoc_bulk_operation_execute() πŸ’«


🌸 PARAMETERS 🌸

  • bulk β€” a mongoc_bulk_operation_t.
  • selector β€” a bson_t that selects which document to remove. (yes, it says remove on this page, we're just reading it fr)
  • document β€” a bson_t containing the update document.
  • error β€” a bson_error_t with any errors that may have occurred.

and now the good part: opts can be NULL, or it can be a BSON document stuffed with extra command options πŸ“

  • validate β€” construct a bitwise-or of all the bson_validate_flags_t you want. set it to false to skip client-side validation of the BSON documents you handed over.
  • collation β€” configures textual comparisons. peep Setting Collation Order and the MongoDB Manual entry on Collation. heads up: collation needs MongoDB 3.2 or later, otherwise an error comes back at you 😭
  • hint β€” a document or string that specifies the index to use to support the query predicate.
  • upsert β€” if true, it inserts a document when nothing matches selector.
  • sort β€” specify a sort order when matching documents.
  • arrayFilters β€” an array of filters specifying which array elements an update should apply to.
⚠️ WARNING: document must only contain fields whose key starts with $. that's not a vibe, that's a rule. see the update document specification for the details πŸ’€

πŸ¦‹ ERRORS πŸ¦‹

operation errors get propagated via mongoc_bulk_operation_execute(), while argument validation errors are reported by the error argument. two different lanes, iykyk 🧚


⭐ RETURNS ⭐

returns true on success, and false if there's a server or network error or if you passed invalid arguments. simple as that πŸ’–

SEE ALSO: mongoc_bulk_operation_update_many_with_opts() β€” go read that one next, bestie 🫢

🌈 AUTHOR 🌈

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole page, periodt πŸ’… this cutie was version 2.5.6, dated Oct 09, 202 (the footer got literally cut off mid-number, rip 😭) β€” love that for us. bye bestie, go queue some updates πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from