MONGOC_BULK_O..._ONE_WITH_OPTS(3)

πŸ’… MONGOC_BULK_O..._ONE_WITH_OPTS(3) πŸ’…

okay so this is a page from libmongoc (section 3, manual-page girlies rise) and it's all about mongoc_bulk_operation_replace_one_with_opts β€” yes the name is long, yes she ate, no we are not abbreviating her πŸ’–


✨ SYNOPSIS ✨

bool
mongoc_bulk_operation_replace_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 */

🌸 DESCRIPTION 🌸

Replace a single document as part of a bulk operation. Only queues the operation, bestie β€” that's the whole vibe. Nothing happens yet!! To actually execute it, you call mongoc_bulk_operation_execute(). Queue first, slay later. πŸŽ€


πŸ¦‹ PARAMETERS πŸ¦‹

  • bulk β€” a mongoc_bulk_operation_t. the main character, obviously πŸ‘‘
  • selector β€” a bson_t that selects which document to remove. (yes, that's what it says, no I'm not changing it, the original said remove and so do I πŸ™ˆ)
  • document β€” a bson_t containing the replacement document. the glow-up in question πŸ’…
  • error β€” a bson_error_t for any errors that may have occurred. the receipts holder 😭

πŸŽ€ opts β€” the optional little extras πŸŽ€

opts may be NULL, or a BSON document with additional command options:

  • validate β€” construct a bitwise-or of all desired bson_validate_flags_t. Set to false to skip client-side validation of the provided BSON documents. no vibe check on your BSON, live your truth ✨
  • collation β€” configure textual comparisons. See Setting Collation Order, and the MongoDB Manual entry on Collation. Collation requires MongoDB 3.2 or later, otherwise an error is returned. periodt β€” old servers get an error, not a pass 🫢
  • hint β€” a document or string that specifies the index to use to support the query predicate. a lil nudge-nudge-wink-wink to the query planner πŸ’–
  • upsert β€” if true, insert a document if none match selector. nobody matched? then she makes one. main character energy fr fr πŸ”₯
  • sort β€” specify a sort order when matching documents. because order matters, always πŸ¦‹
⚠️ WARNING: document may not contain fields with keys containing . or $. like literally do not. πŸ’€

😭 ERRORS 😭

Operation errors are propagated via mongoc_bulk_operation_execute(), while argument validation errors are reported by the error argument. so like... two different pipelines for your problems, iykyk 🌈


⭐ RETURNS ⭐

Returns true on success, and false if passed invalid arguments. simple. iconic. no notes πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€

  • mongoc_bulk_operation_remove_many_with_opts()
  • mongoc_bulk_operation_insert()

go read those too, bestie, they're literally right there 🧚


πŸ™ˆ AUTHOR πŸ™ˆ

MongoDB, Inc β€” kings of the database, honestly πŸ‘‘

2009-present, MongoDB, Inc.


okay that's the whole page!! you understood it, I'm so proud of you πŸ₯ΉπŸ“

libmongoc ✦ version 2.5.6 ✦ Oct 09, 2026 β€” mwah, go replace some documents responsibly, ily πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from