MONGOC_COLLEC...TION_WITH_OPTS(3)

πŸ’… MONGOC_COLLEC...TION_WITH_OPTS(3) πŸ’…

ok so bestie, welcome to libmongoc's mongoc_collection_create_bulk_operation_with_opts page 🌸 this one's short and sweet, so grab a strawberry drink and let's go πŸ“


✨ SYNOPSIS ✨

mongoc_bulk_operation_t *
mongoc_collection_create_bulk_operation_with_opts (
   mongoc_collection_t *collection,
   const bson_t *opts);

πŸŽ€ PARAMETERS πŸŽ€

  • collection β€” a mongoc_collection_t. that's your collection, your main character πŸ‘‘

now opts β€” it can be NULL, or a BSON document stuffed with extra command options πŸ’– here's what you can put in there:

  • writeConcern β€” build yourself a mongoc_write_concern_t and use mongoc_write_concern_append() to add the write concern to opts. the example code for mongoc_client_write_command_with_opts() shows exactly how, iykyk ✨
  • ordered β€” set it to false if you want to attempt to insert all the documents and keep going even after errors happen. no stopping, no quitting, we persist πŸ’€
  • sessionId β€” first, construct a mongoc_client_session_t with mongoc_client_start_session(). then you can begin a transaction with mongoc_client_session_start_transaction(), optionally passing a mongoc_transaction_opt_t that overrides the options inherited from collection, and then use mongoc_client_session_append() to add the session to opts. the example code for mongoc_client_session_t has the whole lore 🫢
  • let β€” a BSON document made of any number of parameter names, each one followed by definitions of constants in the MQL Aggregate Expression language πŸ¦‹
  • comment β€” a bson_value_t that specifies the comment to attach to this command. this comment will show up in log messages, profiler output, and currentOp output πŸ‘€ needs MongoDB 4.4 or later, no cap

πŸ”₯ DESCRIPTION πŸ”₯

this function shall begin a new bulk operation ⭐ and after you create it, you may call various functions like mongoc_bulk_operation_update(), mongoc_bulk_operation_insert(), and others. go off πŸ’…

and after you call mongoc_bulk_operation_execute(), the commands will be executed in as large as batches as reasonable by the client πŸ”₯ literally the client doing the most for you


😭 ERRORS 😭

errors are propagated when executing the bulk operation. that's it, that's the section, don't shoot the messenger πŸ™ˆ


πŸ‘‘ RETURNS πŸ‘‘

a newly allocated mongoc_bulk_operation_t that should be freed with mongoc_bulk_operation_destroy() when it's no longer in use. clean up after yourself bestie, it's giving self-care 🌈

⚠️ WARNING: failure to handle the result of this function is a programming error. like, actual oops. don't do it πŸ’€

SEE ALSO:

  • Bulk Write Operations
  • mongoc_bulk_operation_t

🧚 AUTHOR 🧚

MongoDB, Inc β€” icons only πŸ‘‘

2009-present, MongoDB, Inc.


and that's the whole page, bestie πŸŽ€πŸ’– version 2.5.6, dated Oct 09, 2026 β€” slay, go build something iconic πŸ¦‹βœ¨

πŸ“¦ where this page comes from