MONGOC_URI_NEW_WITH_ERROR(3)

✨ MONGOC_URI_NEW_WITH_ERROR(3) ✨

okay bestie, this is the libmongoc page for mongoc_uri_new_with_error, and it's lowkey iconic because it turns a MongoDB-style URI string into a usable mongoc_uri_t. no cap, this is the glow-up your connection string deserves πŸ’…


✨ SYNOPSIS ✨

here's the signature, bestie β€” copy it exactly, periodt:

mongoc_uri_t *
mongoc_uri_new_with_error (const char *uri_string,
                           bson_error_t *error);

🌸 PARAMETERS 🌸

  • uri_string β€” a string containing a URI. literally the connection string you're feeding in.
  • error β€” an optional location for a bson_error_t or NULL. optional optional, but if you pass it, it's ready to catch the tea when parsing fails.

πŸ¦‹ DESCRIPTION πŸ¦‹

Parses a string containing a MongoDB style URI connection string.

that's it. that's the whole vibe. it takes your URI string and does the parsing thing so you don't have to ✨


πŸ’– RETURNS πŸ’–

A newly allocated mongoc_uri_t if successful. Otherwise NULL populating error with the error description.

⚠️ WARNING: Failure to handle the result of this function is a programming error. like, bestie, please check the return value β€” this is not the moment to be oblivious 😭

πŸŽ€ EXAMPLES πŸŽ€

Examples of some valid MongoDB connection strings can be seen below. all of these are valid, fr fr β€” no guessing, just copy-paste energy:

"mongodb://localhost/"

"mongodb://localhost/?replicaSet=myreplset"

"mongodb://myuser:mypass@localhost/"

"mongodb://kerberosuser%40EXAMPLE.COM@example.com/?authMechanism=GSSAPI"

"mongodb://[::1]:27017/"

"mongodb://10.0.0.1:27017,10.0.0.1:27018,[::1]:27019/?tls=true"

"mongodb://%2Ftmp%2Fmongodb-27017.sock"

"mongodb://user:pass@%2Ftmp%2Fmongodb-27017.sock"

"mongodb://localhost,[::1]/mydb?authSource=mydb"

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the author, periodt πŸ’…


2009-present, MongoDB, Inc.


stay hydrated, bestie 🫢 β€” this page is from libmongoc version 2.5.6, dated Oct 09, 2026, and it's called MONGOC_URI_NEW_WITH_ERROR(3) πŸ’–βœ¨

πŸ“¦ where this page comes from