MONGOC_URI_GET_OPTION_AS_INT64(3)

πŸ’… MONGOC_URI_GET_OPTION_AS_INT64 πŸ’…

okay bestie so this one lives in the libmongoc manual, and it's literally the easiest little guy ever: you hand it a URI, you hand it an option name, and it hands you back a number. That's it. That's the whole vibe. ✨


🌸 SYNOPSIS 🌸

int64_t
mongoc_uri_get_option_as_int64 (const mongoc_uri_t *uri,
                                const char *option,
                                int64_t fallback);

πŸŽ€ PARAMETERS πŸŽ€

  • uri β€” A mongoc_uri_t. your lil URI object, the main character of the whole operation 🫢
  • option β€” The name of an option, case insensitive. so like, don't stress about caps, she doesn't care πŸ’…
  • fallback β€” A default value to return. the safety net, the backup plan, the "if everything else fails, at least you have this" bestie 😌

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea: this function returns the value of the URI option if it's set and it's the correct type (integer, ngl). And it returns fallback if the option is not set, if it's set to an invalid type, or if it's zero. All three of those situations? Straight to fallback. no cap.

⚠️ and this is the important one, bestie: zero is considered "unset". yeah. zero counts as nothing. so if you actually want zero you're out of luck here, she's gonna give you the fallback instead πŸ’€

Which honestly lowkey slaps, because it means you can construct URIs like this and they'll still accept the default values:

bson_strdup_printf ("mongodb://localhost/?wTimeoutMS=%" PRId64, myvalue)

So if myvalue is non-zero, that's your write concern timeout. but if myvalue is zero, the driver just uses the default timeout. iconic behaviour honestly. it's giving "idk just pick for me" 🧚


πŸ‘‘ SEE ALSO πŸ‘‘

  • mongoc_uri_get_option_as_int32() β€” the 32-bit sibling, same energy, smaller numbers 🌈

πŸ’– AUTHOR πŸ’–

MongoDB, Inc β€” the whole entire company, yes, all of them 🌟

2009-present, MongoDB, Inc. β€” and honestly? goals. a copyright span of over a decade and a half. periodt. πŸ’œ


okay that's the page!! if you made it this far ily πŸŽ€ this is from libmongoc 2.5.6, dated Oct 09, 2026 β€” so like, go forth and read your int64s responsibly bestie βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from