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β amongoc_bulk_operation_t.selectorβ abson_tthat selects which document to remove. (yes, it says remove on this page, we're just reading it fr)documentβ abson_tcontaining the update document.errorβ abson_error_twith 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 thebson_validate_flags_tyou want. set it tofalseto 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β iftrue, it inserts a document when nothing matchesselector.sortβ specify a sort order when matching documents.arrayFiltersβ an array of filters specifying which array elements an update should apply to.
β οΈ WARNING:documentmust 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
π COPYRIGHT π
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
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms