MONGOC_URI_SET_DATABASE(3)

πŸ’… MONGOC_URI_SET_DATABASE(3) πŸ’…

okay so bestie, welcome to the glow-up era of libmongoc's mongoc_uri_set_database() β€” the little function that lets you swap out your URI's database after the URI has already been parsed from a string. no re-parsing, no drama, just a clean little setter. πŸŽ€


✨ SYNOPSIS ✨

bool
mongoc_uri_set_database (mongoc_uri_t *uri, const char *database);

literally just one function, two args, returns a bool. iconic signature, no notes. 🫢


🌸 PARAMETERS 🌸

  • uri β€” a mongoc_uri_t. the URI object you're about to mess with, main character of this whole operation.
  • database β€” the new database name. this is the string you're sliding in there, so choose wisely. πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: this sets the URI's database after the URI has been parsed from a string. that's the whole point β€” you don't have to rebuild the connection string from scratch, you just poke the parsed object. lowkey elegant fr fr. ✨

Two very real consequences you should clock:

  • the driver authenticates to this database if the connection string includes authentication credentials. so yeah, this isn't just a cosmetic label β€” it matters for auth. πŸ‘€
  • this database is also the return value of mongoc_client_get_default_database(). so whatever you set here is what comes back out over there. symmetry slay. πŸ’…

⭐ RETURNS ⭐

Returns false if the option cannot be set β€” for example if database is not valid UTF-8. 😭

no cap, that's the failure case to watch for: bad UTF-8 in, false out. check your return value, bestie, don't just vibe past it. 🚨

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the whole squad behind this. πŸ’œ


2009-present, MongoDB, Inc. β€” yes, they've been at this since 2009. legacy behavior, we love to see it. πŸ•°οΈ


okay that's the whole page, go forth and set your databases responsibly, mwah πŸ’‹

sign-off szn: this was libmongoc version 2.5.6, dated Oct 09, 2026 β€” catch you on the next manpage, bestie! πŸ“πŸ§šπŸ’–

πŸ“¦ where this page comes from