MONGOC_COLLECTION_STATS(3)

πŸ’… MONGOC_COLLECTION_STATS(3) β€” the libmongoc page, but make it cute

okay bestie, sit down, hydrate, because we're talking about mongoc_collection_stats() β€” a lil function from the libmongoc manual, section 3. yes it's real, yes it's deprecated, and yes we're still gonna learn it because context is a love language πŸ’–

⚠️ WARNING β€” this one is deprecated since version 1.10.0. the glow-up replacement is the $collStats aggregation pipeline stage, used with mongoc_collection_aggregate(). so like… use that instead, fr fr. πŸ’€

✨ SYNOPSIS ✨

bool
mongoc_collection_stats (mongoc_collection_t *collection,
                         const bson_t *options,
                         bson_t *reply,
                         bson_error_t *error);

that's the whole vibe. four arguments, one bool coming back at you. 🫢


πŸŽ€ PARAMETERS πŸŽ€

  • collection β€” a mongoc_collection_t. your main character. the collection we're snooping on. πŸ‘‘
  • options β€” an optional bson_t holding extra options you wanna pass along to the collStats command. optional optional, no pressure, she's flexible. ✨
  • reply β€” a maybe-NULL pointer to overwritable storage for a bson_t that'll contain the results. "maybe-NULL" β€” so if you pass NULL, that's a choice you're allowed to make, but bestie… πŸ₯΄
  • error β€” an optional place to put a bson_error_t, or NULL. also optional. we love a low-stakes parameter list. πŸ’œ

🌸 DESCRIPTION 🌸

she runs the collStats command and retrieves statistics about the collection. that's the whole job. no cap. πŸ“Š

and the tea β˜•: the command uses the mongoc_read_prefs_t that's set on collection. so whatever read prefs you gave her, that's what she rides with. not a surprise, just how it is. 🌈


πŸ’€ ERRORS πŸ’€

errors get propagated via the error parameter. that's it, that's the section. short and iconic. periodt. ✨


πŸ”₯ RETURNS πŸ”₯

  • returns true if it worked. slay. πŸŽ‰
  • returns false and sets error if there are invalid arguments, or if there's a server error, or a network error. so many ways to have a bad day 😭
🫢 IMPORTANT ONE: reply is always initialized and must be freed with bson_destroy(). always. even if things went sideways. don't leave her hanging, that's a leak and leaks are not cute. πŸ’…

🧚 AUTHOR 🧚

MongoDB, Inc


2009-present, MongoDB, Inc.


okay that's the whole page, you ate that, you're basically a database girlie now πŸ’– go forth and (please) use $collStats with mongoc_collection_aggregate() instead, because this function is deprecated and we don't stan deprecated APIs in this house πŸŽ€πŸ¦‹

this has been the libmongoc MONGOC_COLLECTION_STATS(3) page, version 1.30.13, dated Oct 09, 2026 β€” mwah, bye bestie! πŸŒΈπŸ’œπŸ“

πŸ“¦ where this page comes from