BSON_APPEND_BINARY(3)

πŸ’– BSON_APPEND_BINARY πŸ’–

okay so welcome to the libbson manual page for bson_append_binary(), bestie ✨ this is the one that appends binary data into a BSON document, and it’s honestly kind of a big deal. let’s get into it fr fr.


✨ SYNOPSIS ✨

#define BSON_APPEND_BINARY(b, key, subtype, val, len) \
   bson_append_binary (b, key, (int) strlen (key), subtype, val, len)

bool
bson_append_binary (bson_t *bson,
                    const char *key,
                    int key_length,
                    bson_subtype_t subtype,
                    const uint8_t *binary,
                    uint32_t length);

πŸŽ€ PARAMETERS πŸŽ€

  • bson β€” a bson_t. that’s the document you’re adding to, periodt πŸ’…
  • key β€” the key name. name it cute, name it clear 🫢
  • key_length β€” the length of key in bytes, or -1 to use strlen(). yes, -1 is the β€œjust figure it out” option ✨
  • subtype β€” a bson_subtype_t indicating the binary subtype.
  • binary β€” a buffer to embed as binary data. May be NULL for an empty binary value πŸ™ˆ
  • length β€” the length of buffer in bytes. Must be 0 if binary is NULL. no cap, that condition matters.

🌸 DESCRIPTION 🌸

The bson_append_binary() function shall append a new element to bson containing the binary data provided. that’s the whole vibe: you hand it binary data, it adds a new element to your bson, and it slays πŸ’–


πŸ¦‹ RETURNS πŸ¦‹

Returns true if the operation was applied successfully. the function will fail if appending binary grows bson larger than INT32_MAX β€” so yeah, there’s a size limit, bestie, and it is not a suggestion πŸ’€

SEE ALSO: bson_append_binary_uninit()


🫢 AUTHOR 🫢

MongoDB, Inc


2009-present, MongoDB, Inc.


catch you later β€” this was the BSON_APPEND_BINARY(3) page from libbson 2.5.6, dated Oct 09, 2026. go append some binary, bestie πŸ’…βœ¨

πŸ“¦ where this page comes from