BSON_APPEND_DBPOINTER(3)

πŸ’… BSON_APPEND_DBPOINTER ✨

okay bestie so this one lives in libbson (that's the BSON_APPEND_DBPOINTER(3) situation, iykyk) and it's your girl for appending a dbpointer field to a BSON document. it's giving very niche, very legacy, but she ate πŸ’…


🌸 SYNOPSIS 🌸

here's the whole vibe, both forms, copy-paste approved:

#define BSON_APPEND_DBPOINTER(b, key, coll, oid) \
   bson_append_dbpointer (b, key, (int) strlen (key), coll, oid)

bool
bson_append_dbpointer (bson_t *bson,
                       const char *key,
                       int key_length,
                       const char *collection,
                       const bson_oid_t *oid);

so the macro is the lazy-girl route (it does the strlen for you, iconic) and the function is the full-control route πŸŽ€


πŸ¦‹ PARAMETERS πŸ¦‹

  • bson β€” a bson_t. that's your document, your main character, the thing you're appending to ✨
  • key β€” an ASCII C string with the name of the field. just ASCII, bestie, don't get fancy πŸ™ˆ
  • key_length β€” the length of key in bytes, or -1 to let it figure the length out with strlen(). the -1 is literally the "you handle it" option and we respect it πŸ’…
  • collection β€” the target collection name 🌸
  • oid β€” the target document identifier. it's a const bson_oid_t *, so a pointer, don't forget the & 🫢

⭐ DESCRIPTION ⭐

okay so this appends a dbpointer field to your bson_t. simple. clean. done.

⚠️ WARNING, and I need you to actually read this one, bestie: the dbpointer field type is DEPRECATED 😭 and should only be used when interacting with legacy systems. like, legacy legacy. if you're out here choosing dbpointer for a fresh new project, what are you doing πŸ’€

πŸ”₯ RETURNS πŸ”₯

returns true if the operation was applied successfully β€” slay πŸŽ‰

but ngl, the function will fail if appending the array grows bson larger than INT32_MAX. that's the limit, that's the ceiling, no cap 🧚


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the ones who wrote it, the ones to thank πŸ’œ


2009-present, MongoDB, Inc. β€” all the legal sparkle, preserved exactly ✨


that's the whole page, bestie, every flag and caveat intact and nothing invented, fr fr 🫢 stay safe out there and remember: dbpointer is legacy only, periodt πŸ’…

β€” with love from libbson 2.5.6, dated Oct 09, 2026 πŸŽ€πŸ¦‹β­

πŸ“¦ where this page comes from