BSON_APPEND_ARRAY_FROM_VECTOR(3)
π 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β abson_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 longkeyis, in bytes. or pass-1and it'll figure it out withstrlen()all on its own, lowkey iconic πiterβ abson_iter_tpointing 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
bsonlarger thanINT32_MAXπ (yeah, that's the ceiling, respect it) - or if
iterdoesn'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 π
β COPYRIGHT β
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
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms