BSON_HAS_FIELD(3)

πŸ’… BSON_HAS_FIELD(3) β€” the libbson glow-up

Okay bestie, so you're poking around in libbson and you need to know if some field is actually in there before you go grabbing it like it owes you money. That's literally what bson_has_field is for. It's a vibe check for keys. πŸŽ€


✨ SYNOPSIS ✨

bool
bson_has_field (const bson_t *bson, const char *key);

That's it. That's the whole signature. Two args, one bool back. Iconic behavior, no notes. 🫢


🌸 PARAMETERS 🌸

  • bson β€” a bson_t. Yeah, the actual document you're digging through, bestie. Not a copy, not a vibe, the real thing.
  • key β€” a string holding the name of the field you wanna check for. This is your little search term. πŸ”

πŸ¦‹ DESCRIPTION πŸ¦‹

So what it does: it checks to see if key contains an element named key. That's the check. Simple, clean, slay.

And here's the part that's giving main character energy: it also accepts "dotkey" notation like "a.b.c.d". So you can reach all the way down into nested documents without doing the whole manual descend-yourself thing. Ngl, that's the feature. That's the moment. ✨

"a.b.c.d"

Just pass it in and let it cook. πŸ”₯


⭐ RETURNS ⭐

  • true if key was found within bson πŸ’–
  • otherwise false πŸ’€

No in-between, no "maybe", no situationship. It's a bool, it commits.


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


Fr fr, that's the whole page β€” nothing hiding in the fine print. Go check your fields, bestie. 🧚

That was BSON_HAS_FIELD(3) from libbson, version 2.5.6, dated Oct 09, 2026 β€” mwah, talk later πŸ’œ

πŸ“¦ where this page comes from