MONGOC_CLIENT_...FAULT_DATABASE(3)

πŸ’– bestie, you're on the MONGOC_CLIENT_...FAULT_DATABASE(3) page from libmongoc πŸ’–

okay so this is the whole glow-up of that manpage, and we're keeping every crumb. no cap. 🫢

✨ SYNOPSIS ✨

          mongoc_database_t *
          mongoc_client_get_default_database (mongoc_client_t *client);

okay so what does it do? It gets the database named in the MongoDB connection URI, or returns NULL if the URI specifies none. Useful when you want to choose which database to use based only on the URI in a configuration file. periodt. πŸ’…

πŸŽ€ PARAMETERS πŸŽ€

  • client β€” a mongoc_client_t. that's the whole vibe. ✨

🌟 RETURNS 🌟

A newly allocated mongoc_database_t that should be freed with mongoc_database_destroy(). don't forget the cleanup, bestie 😭

πŸ“ EXAMPLE πŸ“

🌈 Default Database Example 🌈

          /* default database is "db_name" */
          mongoc_client_t *client = mongoc_client_new ("mongodb://host/db_name");
          mongoc_database_t *db = mongoc_client_get_default_database (client);

          assert (!strcmp ("db_name", mongoc_database_get_name (db)));

          mongoc_database_destroy (db);
          mongoc_client_destroy (client);

          /* no default database */
          client = mongoc_client_new ("mongodb://host/");
          db = mongoc_client_get_default_database (client);

          assert (!db);

          mongoc_client_destroy (client);

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc πŸ’œ

2009-present, MongoDB, Inc.


mwah πŸ’‹ and that's the tea: MONGOC_CLIENT_...FAULT_DATABASE(3) from libmongoc, version 2.5.6, dated Oct 09, 202. slay and read the docs, bestie πŸ¦‹βœ¨

πŸ“¦ where this page comes from