BSON_APPEND_OID(3)
π BSON_APPEND_OID(3) β libbson, bestie
okay so you're here because you wanna shove an ObjectId into a BSON document and you want the group chat to explain it. no worries, this is literally the libbson manual page for BSON_APPEND_OID, and it's giving "tiny function, big slay". β¨
π SYNOPSIS
Here's the macro, and here's the actual function it wraps β both, verbatim, because we don't gatekeep:
#define BSON_APPEND_OID(b, key, val) \
bson_append_oid (b, key, (int) strlen (key), val)
bool
bson_append_oid (bson_t *bson,
const char *key,
int key_length,
const bson_oid_t *oid);
πΈ PARAMETERS
bsonβ abson_t. that's your document, the main character π«Άkeyβ an ASCII C string with the field name. ASCII specifically, bestie, don't get cute with it.key_lengthβ how longkeyis, in bytes. pass-1and it'll figure the length out withstrlen()for you πoidβ abson_oid_t. yes. one of those.
π¦ DESCRIPTION
bson_append_oid() appends a brand-new element to bson, and the type of that element is BSON_TYPE_OID. that's it, that's the whole vibe. π
β οΈoidMUST be a pointer to abson_oid_t. like, non-negotiable. no cap.
β RETURNS
returns true if the operation went through successfully β slay, it worked π
it will fail if appending oid grows bson larger than INT32_MAX. yeah. there's a ceiling. iconic but firm. π
π AUTHOR
MongoDB, Inc
π COPYRIGHT
2009-present, MongoDB, Inc.
and that's the whole page, bestie β go forth and append those OIDs π§
sign-off tingz: this was libbson version 2.5.6, dated Oct 09, 2026. mwah π
π¦ 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