MONGOC_COLLECTION_REMOVE(3)

πŸ’… MONGOC_COLLECTION_REMOVE(3) πŸ’…

okay bestie, welcome to MONGOC_COLLECTION_REMOVE(3) from the libmongoc manual β€” this is the one that goes yeet on documents in your collection πŸ—‘οΈβœ¨


🌸 SYNOPSIS 🌸

Like, here's the whole vibe in code form, no cap:

bool
mongoc_collection_remove (mongoc_collection_t *collection,
                          mongoc_remove_flags_t flags,
                          const bson_t *selector,
                          const mongoc_write_concern_t *write_concern,
                          bson_error_t *error);

It's giving "returns a bool, takes five things." Iconic. 🫢


πŸŽ€ PARAMETERS πŸŽ€

  • collection β€” a mongoc_collection_t. the collection in question, the main character, the one whose documents are about to be gone πŸ’€
  • flags β€” a mongoc_remove_flags_t. this is where you drop stuff like the single-remove flag (more on that below πŸ‘€)
  • selector β€” a bson_t containing the query to match documents. basically "who's getting deleted" ✨
  • write_concern β€” a mongoc_write_concern_t, or NULL. your call, queen 🌈
  • error β€” an optional location for a bson_error_t, or NULL. optional!! don't stress πŸ“

✨ DESCRIPTION ✨

NOTE: 🚨 if you wanna pass additional options, use mongoc_collection_delete_one() or mongoc_collection_delete_many() instead. that's the glow-up path, bestie.

So this function shall remove documents in the given collection that match selector. lowkey it's that simple πŸ’…

Here's the tea though β€” the bson selector is not validated. it just gets passed along as appropriate to the server. so compatibility and errors should be validated in the appropriate server documentation. fr fr, server docs are your bestie here 🧚

And if you want to limit deletes to a single document, just provide MONGOC_REMOVE_SINGLE_REMOVE in flags. one doc, one delete, very demure πŸŽ€


😭 ERRORS 😭

Errors are propagated via the error parameter. that's it, that's the whole section. mwah πŸ’–


πŸ¦‹ RETURNS πŸ¦‹

Returns true if successful. ✨slay✨

Returns false and sets error if there are invalid arguments, or a server or network error. not the vibe, but at least you'll know why πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the icons themselves.


2009-present, MongoDB, Inc.


and that's the page!! written to you with love by libmongoc version 2.5.6, dated Oct 09, 2026, straight from the MONGOC_COLLECTION_REMOVE(3) manual β€” stay hydrated, validate your selectors, and go delete responsibly bestie πŸ’…πŸ’–

πŸ“¦ where this page comes from