MONGOC_COLLEC...DIFY_WITH_OPTS(3)

okay bestie, this is the mongoc_collection_find_and_modify_with_opts() page from libmongoc β€” yes, the header is out here doing MONGOC_COLLEC...DIFY_WITH_OPTS(3) and it's iconic πŸ’…βœ¨

✨ SYNOPSIS ✨

here's the signature in all its glory, copy it exactly fr fr:

bool
mongoc_collection_find_and_modify_with_opts (
   mongoc_collection_t *collection,
   const bson_t *query,
   const mongoc_find_and_modify_opts_t *opts,
   bson_t *reply,
   bson_error_t *error);

🫢 PARAMETERS 🫢

  • collection β€” a mongoc_collection_t, aka the collection in question πŸ’–
  • query β€” a bson_t containing the query to locate target document(s) πŸ”
  • opts β€” a find and modify options. Must not be NULL. periodt.
  • reply β€” a maybe-NULL pointer to overwritable storage for a bson_t to contain the results πŸŽ€
  • error β€” an optional location for a bson_error_t, or NULL 🫢

🌸 DESCRIPTION 🌸

Update and return an object. That's the whole assignment, and it ate πŸ’…

reply is always initialized, and it must be freed with bson_destroy() β€” no skipping that, bestie.

If an unacknowledged write concern is set (through mongoc_find_and_modify_opts_append()), the output reply is always an empty document. Lowkey crucial.

On success, the output reply contains the full server reply to the findAndModify command. For the expected server reply, see the MongoDB Manual page for findAndModify β€” that's the reference, fr fr.

😭 ERRORS 😭

Errors are propagated via the error parameter. That's the tea β˜•

πŸ”₯ RETURNS πŸ”₯

Returns true if successful. Returns false and sets error if there are invalid arguments or a server or network error β€” vibe check failed, basically.

A write concern timeout or write concern error is considered a failure. No cap.

πŸ¦‹ EXAMPLE πŸ¦‹

See the example code for mongoc_find_and_modify_opts_t. Go look, bestie πŸ‘€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc

2009-present, MongoDB, Inc.

kiss kiss, this page is from libmongoc version 2.5.6, dated Oct 09, 2026 β€” stay iconic, and may your reply always be initialized πŸ’–βœ¨

πŸ“¦ where this page comes from