BSON_APPEND_DOCUMENT(3)
π BSON_APPEND_DOCUMENT(3) β the libbson glow-up
okay bestie, so this is a page straight out of libbson and it's genuinely one of the cutest little functions ever. it appends a document inside another document. nesting!! we love to see it. πͺβ¨
πΈ SYNOPSIS πΈ
#define BSON_APPEND_DOCUMENT(b, key, val) \
bson_append_document (b, key, (int) strlen (key), val)
bool
bson_append_document (bson_t *bson,
const char *key,
int key_length,
const bson_t *value);
so you've got two entry points, iykyk: the macro BSON_APPEND_DOCUMENT which is literally just a lil shortcut that calls strlen on your key for you (so your key has to be a NUL-terminated C string, no funny business), and the real function bson_append_document where you pass the length yourself. main character energy. π
π PARAMETERS π
bsonβ abson_t. this is the doc you're stuffing stuff into. the host. the parent. the mother if you will. π«Άkeyβ an ASCII C string holding the name of the field. keep it ASCII, bestie, that's the assignment. β¨key_lengthβ the length ofkeyin bytes. or, and this is the fun part, pass-1and it'll figure out the length itself withstrlen(). lowkey magical. πͺvalueβ abson_tcontaining the sub-document you wanna append. the child!! the baby!! π£
π¦ DESCRIPTION π¦
bson_append_document() shall append child to bson using the specified key. and like β the type of the field? it's gonna be a document. that's it. that's the vibe. a document inside a document, no cap. π
π₯ RETURNS π₯
returns true if the operation was applied successfully. slay. β
but β and listen, this is important β the function will fail if appending value grows bson larger than INT32_MAX. π that's a hard limit, not a suggestion, so don't come crying to me when your mega-doc doesn't fit. check your return value, fr fr.
π AUTHOR π
MongoDB, Inc β the icons who brought you this whole thing. π
π COPYRIGHT π
2009-present, MongoDB, Inc. π«‘
and that's the whole page, bestie!! go forth and nest those documents responsibly π β¨
β libbson version 2.5.6, dated Oct 09, 2026 π mwah, ily, bye!! π«Ά
π¦ 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