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β amongoc_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. π
π COPYRIGHT π
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
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms