BSON_TYPE_T(3)
β¨ BSON Type Enumeration β¨
okay bestie, welcome to the libbson page for BSON_TYPE_T(3) β aka bson_type_t. This is the enum holding every single BSON type from the BSON Specification, and it's giving type-identifying main character energy. It can be used to determine the type of a field at runtime. no cap. π
πΈ SYNOPSIS πΈ
#include <bson/bson.h>
typedef enum {
BSON_TYPE_EOD = 0x00,
BSON_TYPE_DOUBLE = 0x01,
BSON_TYPE_UTF8 = 0x02,
BSON_TYPE_DOCUMENT = 0x03,
BSON_TYPE_ARRAY = 0x04,
BSON_TYPE_BINARY = 0x05,
BSON_TYPE_UNDEFINED = 0x06,
BSON_TYPE_OID = 0x07,
BSON_TYPE_BOOL = 0x08,
BSON_TYPE_DATE_TIME = 0x09,
BSON_TYPE_NULL = 0x0A,
BSON_TYPE_REGEX = 0x0B,
BSON_TYPE_DBPOINTER = 0x0C,
BSON_TYPE_CODE = 0x0D,
BSON_TYPE_SYMBOL = 0x0E,
BSON_TYPE_CODEWSCOPE = 0x0F,
BSON_TYPE_INT32 = 0x10,
BSON_TYPE_TIMESTAMP = 0x11,
BSON_TYPE_INT64 = 0x12,
BSON_TYPE_DECIMAL128 = 0x13,
BSON_TYPE_MAXKEY = 0x7F,
BSON_TYPE_MINKEY = 0xFF,
} bson_type_t;
π¦ DESCRIPTION π¦
The bson_type_t enumeration contains all of the types from the BSON Specification. It can be used to determine the type of a field at runtime β yes, literally that. iconic behavior only. β¨
π EXAMPLE π
bson_iter_t iter;
if (bson_iter_init_find (&iter, doc, "foo") &&
(BSON_TYPE_INT32 == bson_iter_type (&iter))) {
printf ("'foo' is an int32.\n");
}
this little snippet is the moment. tiny, clean, and doing exactly the check it says on the box. π
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
π«Ά shoutout to libbson version 2.5.6, dated Oct 09, 2026 β that's the source/version/date footer energy, bestie. periodt. π
π¦ 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