MONGOC_DATABAS...ND_COLLECTIONS(3)

πŸ’– mongoc_database_find_collections πŸ’–

okay bestie, we're in the libmongoc manual, and today's main character is mongoc_database_find_collections β€” a real one, even if it's, um, a little vintage now. 🫢


⚠️ WARNING ⚠️

Deprecated since version 1.9.0: use mongoc_database_find_collections_with_opts() instead. 😭

no cap, this one is in its retired era. she still works, but the glow-up version is mongoc_database_find_collections_with_opts(). go text her. πŸ’…

✨ SYNOPSIS ✨

mongoc_cursor_t *
mongoc_database_find_collections (mongoc_database_t *database,
                                  const bson_t *filter,
                                  bson_error_t *error);

🌸 DESCRIPTION 🌸

She fetches a cursor stuffed with documents, and each one of those documents corresponds to a collection on this database. like, one doc per collection, periodt. πŸŽ€

This function is considered a retryable read operation. so if a transient error happens β€” think a network error, errors due to replica set failover, etc. β€” the operation is safely retried once. iconic resilience honestly. 🌈

BUT. if retryreads is false in the URI (see mongoc_uri_t), the retry behavior does not apply. so, y'know, vibe check your URI first. πŸ‘‘


πŸ¦‹ PARAMETERS πŸ¦‹

  • database β€” a mongoc_database_t. the database we're snooping through. πŸ”
  • filter β€” a matcher used by the server to filter the returned collections. May be NULL. no filter, no problem, she'll show you everything.
  • error β€” an optional location for a bson_error_t, or NULL. your little oopsie-daisy inbox. πŸ™ˆ

πŸ’€ ERRORS πŸ’€

Errors are propagated via the error parameter. that's the whole tea. if something goes sideways, it lands in your bson_error_t. β˜•


πŸ‘‘ RETURNS πŸ‘‘

This function returns a newly allocated mongoc_cursor_t that should be freed with mongoc_cursor_destroy() when no longer in use, or NULL in case of error. ✨

⚠️ bestie, listen: the user must call mongoc_cursor_next() on the returned mongoc_cursor_t to execute the initial command. she does not run on her own. you gotta poke her. 🫡

In the returned cursor, each result corresponds to the server's representation of a collection in this database. so like, what the server says a collection is β€” not your parasocial idea of it. πŸ’…

And a lil 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. don't bother, they're giving nothing here. 🚫


🧚 AUTHOR 🧚

MongoDB, Inc


2009-present, MongoDB, Inc.


and that's the whole page, babe. this was libmongoc version 1.30.13, dated Oct 09, 202… πŸ’– mwah, go free your cursors and hydrate. πŸ“

πŸ“¦ where this page comes from