bson_t3
BSON Document Abstraction
Overview
The bson_t structure represents a BSON document. This structure manages the underlying BSON encoded buffer. For mutable documents, it can append new data to the document.
Performance notes
The bson_t structure attempts to use an inline allocation within the structure to speed up performance of small documents. When this internal buffer has been exhausted, a heap allocated buffer will be dynamically allocated. Therefore, it is essential to call bson_destroy() on allocated documents.
Duplicate keys
The BSON specification allows BSON documents to have duplicate keys. Documents are stored as an ordered list of key-value pairs. A bson_t may contain duplicate keys. Applications should refrain from generating such documents, because MongoDB server behavior is undefined when a BSON document contains duplicate keys.
Examples
static void
create_on_heap (void)
{
bson_t *b = bson_new ();
BSON_APPEND_INT32 (b, "foo", 123);
BSON_APPEND_UTF8 (b, "bar", "foo");
BSON_APPEND_DOUBLE (b, "baz", 1.23f);
bson_destroy (b);
}
History
- Debian 13 (Trixie): the text shown here
- Debian 12 (Bookworm)
- Debian 11 (Bullseye)
- Debian 10 (Buster)
- Debian 9 (Stretch)