BSON_APPEND_BOOL(3)

πŸ’– BSON_APPEND_BOOL(3) πŸ’–

okay bestie, so this is a page from libbson β€” it's the BSON_APPEND_BOOL(3) situation and honestly it's a short one, so we're gonna get through it together, no stress 🫢


✨ SYNOPSIS ✨

you got two flavors, the macro and the real one:

#define BSON_APPEND_BOOL(b, key, val) \
   bson_append_bool (b, key, (int) strlen (key), val)

bool
bson_append_bool (bson_t *bson, const char *key, int key_length, bool value);

the macro is giving "convenience era" β€” it literally just fills in the length for you with strlen. iconic πŸ’…


🌸 PARAMETERS 🌸

  • bson β€” a bson_t. it's the doc you're stuffing stuff into, the main character of the whole operation πŸ‘‘
  • key β€” the name of the field. what you're calling it, bestie ✨
  • key_length β€” the length of key, or -1 if you want it to just use strlen(). lowkey the lazy-but-valid route, we respect it πŸ™ˆ
  • value β€” true or false. that's it. that's the whole vibe check β€” it's a bool, there's only two options πŸ’€

πŸ¦‹ DESCRIPTION πŸ¦‹

so bson_append_bool() shall append a new element to bson containing the boolean you handed it. yes, "shall" β€” very official of it. it's just adding a lil true-or-false to your document and calling it a day. no cap, that's the whole thing 🌈


⭐ RETURNS ⭐

it returns true if the operation was applied successfully πŸ’–

but heads up β€” it will fail if appending the value grows bson larger than INT32_MAX. that's the line, bestie, don't cross it. big numbers are not it here 😭πŸ”₯


πŸŽ€ AUTHOR πŸŽ€

MongoDB, Inc β€” the ones who brought you this whole libbson moment πŸ’œ


2009-present, MongoDB, Inc. β€” yeah, they've been at it a minute. legends, honestly 🫑


and that's the page, bestie!! short and sweet. anyway this was BSON_APPEND_BOOL(3), version 2.5.6, dated Oct 09, 2026 β€” write it down, remember it, slay πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from