MONGOC_COLLECTION_FIND_INDEXES(3)
π MONGOC_COLLECTION_FIND_INDEXES π
okay bestie, gather round, because we're talking about mongoc_collection_find_indexes() from libmongoc β and the very first thing you need to know is that this one is old. Like, vintage. It's still here, it still works, but it's giving "my mom's Facebook account" energy. π«Ά
WARNING: Deprecated since version 1.9.0: Use mongoc_collection_find_indexes_with_opts() instead. π
β¨ SYNOPSIS β¨
mongoc_cursor_t *
mongoc_collection_find_indexes (mongoc_collection_t *collection,
bson_error_t *error);
So what does it do, you ask? It fetches a cursor containing documents, and each of those documents corresponds to an index on this collection. That's it, that's the whole vibe. πΈ
Also important: this function is considered a retryable read operation. So if a transient error shows up β think a network error, or errors due to replica set failover, etc. β the operation is safely retried once. One retry, no cap. But if retryreads is false in the URI (peep mongoc_uri_t), then the retry behavior does not apply. Sorry babe, rules are rules. π
π PARAMETERS π
collectionβ amongoc_collection_t. The collection, bestie. The one with the indexes.errorβ an optional location for abson_error_t, orNULL. Optional means optional, but you know how we feel about optional error params. π
π ERRORS π
Errors are propagated via the error parameter. Simple. Clean. Iconic.
π¦ RETURNS π¦
This function returns a newly allocated mongoc_cursor_t that should be freed with mongoc_cursor_destroy() when it's no longer in use. And listen β the returned mongoc_cursor_t is never NULL, even on error. Not once. Not ever. So don't be out here checking it for NULL like it's gonna save you. π
The user must call mongoc_cursor_next() on the returned mongoc_cursor_t to execute the initial command. Like, nothing happens until you poke it. It's a sleepy little cursor. π
Cursor errors can be checked with mongoc_cursor_error_document(). It always fills out the bson_error_t if an error occurred, and it optionally includes a server reply document if the error occurred server-side. So you get the tea either way, and sometimes you get the full tea. β
WARNING: Failure to handle the result of this function is a programming error. Not a vibe. Not a slay. A programming error. Handle your cursor, bestie. π₯
In the returned cursor, each result corresponds to the server's representation of an index on this collection. And if the collection does not exist on the server? The cursor will be empty. Just an empty little cursor. Nothing in it. We've all been there. π
Also, heads up: the cursor functions mongoc_cursor_set_limit(), mongoc_cursor_set_batch_size(), and mongoc_cursor_set_max_await_time_ms() have no use on the returned cursor. Like, zero. Don't call them on this cursor, they're not for this cursor. It's giving "wrong group chat." π
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
and that's the whole page, babe π this was libmongoc version 1.30.13, dated Oct 09, 2026 β now go use mongoc_collection_find_indexes_with_opts() like the main character you are, and stop calling the deprecated one. iykyk. β¨π¦π
π¦ where this page comes from
- fedora 43: mongo-c-driver-devel 1.30.13-1.fc43 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- fedora 43: mongo-c-driver-devel 1.30.13-1.fc43 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms