BSON_APPEND_ARRAY(3)

πŸ’… BSON_APPEND_ARRAY(3) β€” the libbson glow-up πŸŽ€

okay bestie, so this is the libbson page for BSON_APPEND_ARRAY(3) and it's literally the moment your field gets to be an array. iconic behavior. let's get into it ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the convenience macro, and yes she's just doing strlen for you because she's sweet like that:

#define BSON_APPEND_ARRAY(b, key, val) \
   bson_append_array (b, key, (int) strlen (key), val)

and here's the real function, the main character:

bool
bson_append_array (bson_t *bson,
                   const char *key,
                   int key_length,
                   const bson_t *array);

🌸 PARAMETERS 🌸

  • bson β€” a bson_t. that's the doc you're appending into, the vibe container πŸ’–
  • key β€” an ASCII C string holding the name of the field. name her, bestie ✨
  • key_length β€” how long key is in bytes, or pass -1 and the function will figure it out with strlen() for you. lowkey the -1 is the move 🫢
  • array β€” a bson_t. this is the thing becoming your array πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

bson_append_array() shall append array to bson using the key you specified. so far so slay πŸ’…

the type of the field will be an array β€” but here's the part where you gotta pay attention ngl: it is the responsibility of the caller to make sure the keys of array are properly formatted with string keys like "0", "1", "2" and so forth. that's on you, bestie. the function is not gonna do that for you. no cap 😭


⭐ RETURNS ⭐

returns true if the operation was applied successfully πŸŽ‰

the function fails if appending the array grows bson larger than INT32_MAX. that's the ceiling, and she will not go past it 🚧

ok that's the hard limit, INT32_MAX, not vibes-based. respect it πŸ’€

🌈 SEE ALSO 🌈

SEE ALSO: bson_array_builder_t β€” go look at her, she's right there 🧚

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the icons themselves 🫢


2009-present, MongoDB, Inc. β€” periodt πŸ’…


and that's the whole page, bestie!! this was BSON_APPEND_ARRAY(3) out of libbson version 2.5.6, dated Oct 09, 2026 β€” go forth and format your keys "0", "1", "2" like the icon you are πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from