BSON_APPEND_ARRAY_FROM_VECTOR(3)

πŸ“¦
version 2.5.6 Β· 3 versions
, in epel 10

πŸ’… BSON_APPEND_ARRAY_FROM_VECTOR(3) πŸ’…

okay so bestie, this one lives in the libbson manual, and it's literally about turning a Vector into a plain old BSON Array πŸ¦‹ stay with me, it's not as scary as the name looks.


✨ SYNOPSIS ✨

#define BSON_APPEND_ARRAY_FROM_VECTOR(b, key, iter) \
   bson_append_array_from_vector (b, key, (int) strlen (key), iter)

bool
bson_append_array_from_vector (bson_t *bson,
                               const char *key,
                               int key_length,
                               const bson_iter_t *iter);

so there's the cute little macro shortcut up top πŸ‘† (it just does the strlen (key) for you, iykyk) and the real function underneath. both, verbatim, no notes. πŸŽ€


🌸 PARAMETERS 🌸

  • bson β€” a bson_t. that's the doc you're writing into, the main character πŸ’…
  • key β€” an ASCII C string holding the name of the field. name your child!!
  • key_length β€” how long key is, in bytes. or pass -1 and it'll figure it out with strlen() all on its own, lowkey iconic πŸ™ˆ
  • iter β€” a bson_iter_t pointing to any supported BSON Binary Vector subtype field. yes, any supported one, okurrr ⭐

πŸ¦‹ DESCRIPTION πŸ¦‹

the whole vibe: it converts the Vector that iter is pointing at into a plain BSON Array, and writes it to bson under the name key.

that's it. that's the function. vector in, array out, slay ✨


πŸ‘‘ RETURNS πŸ‘‘

it returns true if the operation was applied successfully. success!! we love to see it πŸ’–

but ngl, it can fail too, and here's exactly when (no cap, memorize these):

  • if appending the array grows bson larger than INT32_MAX 😭 (yeah, that's the ceiling, respect it)
  • or if iter doesn't point to a valid recognized Vector type πŸ’€
fr fr, if your iter is pointing at some random thing that isn't a legit recognized Vector, this function is gonna be like "not my problem" and fail.

🌈 SEE ALSO 🌈

  • bson_array_builder_append_vector_elements()

go read that one next, bestie, it's giving related 🫢


πŸŽ€ AUTHOR πŸŽ€

MongoDB, Inc β€” yes, the whole company. collectively. as a treat πŸ’œ


2009-present, MongoDB, Inc. β€” protect it, it's theirs πŸ‘‘


and that's the page, babe πŸ’… this was 2.5.6 of libbson, dated Oct 09, 2026 β€” go forth and convert those vectors, you've got this πŸ¦‹βœ¨

πŸ“¦ where this page comes from