BSON_APPEND_VALUE(3)
π BSON_APPEND_VALUE(3) β the libbson era, bestie
okay so picture this: you're out here in libbson land and you need to append a value to a bson_t without knowing its type until, like, runtime. that's literally what this function is for. main character energy fr. π
β¨ SYNOPSIS β¨
the convenient macro version (it does the strlen for you, so you don't have to):
#define BSON_APPEND_VALUE(b, key, val) \
bson_append_value (b, key, (int) strlen (key), (val))
and the actual real one, the whole signature, exactly as it is, no cap:
bool
bson_append_value (bson_t *bson,
const char *key,
int key_length,
const bson_value_t *value);
π¦ PARAMETERS π¦
bson: Abson_t. the doc you're being nice to πkey: An ASCII C string containing the name of the field. like the label on the box π·οΈkey_length: The length ofkeyin bytes, or-1to determine the length withstrlen(). yes,-1is the "figure it out yourself bestie" setting π«Άvalue: Abson_value_t. this is the actual thing getting yeeted in there β¨
πΈ DESCRIPTION πΈ
Appends a new field to bson by determining the boxed type in value. so it peeks inside the bson_value_t, sees what type it's carrying, and appends accordingly β iconic behaviour honestly π
the way that this is useful: when you want to copy fields between documents but do not know the field type until runtime. you're just a little courier moving values around, no type knowledge required, slay π
π₯ RETURNS π₯
Returns true if the operation was applied successfully.
β οΈ heads up bestie: the function will fail if appending the value growsbsonlarger thanINT32_MAX. like, there's a ceiling, and that's it. no notes π
π AUTHOR π
MongoDB, Inc β yes that MongoDB, the whole entire company π
π COPYRIGHT π
2009-present, MongoDB, Inc. β they've been at this a minute, fr fr.
and that's the page!! β¨ this was libbson version 2.5.6 from Oct 09, 2026 β go forth and append your values, bestie, 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