arr() = [value()]
Caution, a string() will be interpreted as an array of integers. You must supply strings as utf8 binary, see below.
bfunction() = {bin, function, binary()}
bin() = {bin, bin, binary()}
bin_old() = {bin, bin_old, binary()}
document() = tuple()
{label(), value(), label(), value(), ...}. Conceptually a document is a list of label-value pairs (associative array, dictionary, record). However, for read/write-ability, it is implemented as a flat tuple, ie. the list becomes a tuple and the pair braces are elided, so you just have alternating labels and values where each value is associated with the previous label. To distinguish a tagged value such as {uuid, _} (see value() type below) from a document with field name 'uuid' we made sure all valid tagged value types have an odd number of elements (documents have even number of elements). So actually only {bin, uuid, _} is a valid value, {uuid, _} is a document.
javascript() = {javascript, document(), utf8()}
scope and code
label() = binary() | atom()
md5() = {bin, md5, binary()}
minmaxkey() = 'MIN_KEY' | 'MAX_KEY'
Special values that compare lower/higher than all other bson values
mongostamp() = {mongostamp, integer(), integer()}
4-byte increment, 4-byte timestamp. 0 timestamp has special semantics
objectid() = {<<_:96>>}
<<UnixTimeSecs:32/big, MachineId:24/big, ProcessId:16/big, Count:24/big>>
regex() = {regex, utf8(), utf8()}
pattern and options
unixsecs() = integer()
Unix Time in seconds
unixtime() = {integer(), integer(), integer()}
{MegaSecs, Secs, MicroSecs} Unix time in Erlang now/os:timstamp format, but only to millisecond precision when serialized.
userdefined() = {bin, userdefined, binary()}
utf8() = unicode:unicode_binary()
binary() representing a string of characters encoded with UTF-8.
An Erlang string() is a list of unicode characters (codepoints), but this list must be converted to utf-8 binary for use in Bson.
Call utf8/1 to do this, or encode pure ascii literals directly as <<"abc">>
and non-pure ascii literals as <<"a�c"/utf8>>
.
uuid() = {bin, uuid, binary()}
uuid_old() = {bin, uuid_old, binary()}
value() = float() | utf8() | document() | arr() | bin() | bfunction() | bin_old() | uuid_old() | uuid() | md5() | userdefined() | objectid() | boolean() | unixtime() | null | regex() | javascript() | atom() | integer() | mongostamp() | minmaxkey()
append/2 | Append two documents together. |
at/2 | Value of field in document, error if missing. |
doc_foldl/3 | Reduce document by applying given function to each field with result of previous field's application, starting with given initial result. |
doc_foldr/3 | Same as doc_foldl/3 except apply fields in reverse order. |
document/1 | Convert list of fields to a document. |
exclude/2 | Remove given fields from document. |
fields/1 | Convert document to a list of all its fields. |
flatten_map/1 | |
include/2 | Project given fields of document. |
lookup/2 | Value of field in document if there. |
lookup/3 | Value of field in document if there or default. |
merge/2 | First doc overrides second with new fields added at end of second doc. |
merge/3 | |
ms_precision/1 | Truncate microsecs to millisecs since bson drops microsecs anyway, so time will be equal before and after serialization. |
objectid/3 | |
objectid_time/1 | Time when object id was generated. |
secs_to_unixtime/1 | |
str/1 | Convert utf8 binary to string. |
timenow/0 | |
unixtime_to_secs/1 | |
update/3 | Replace field with new value, adding to end if new. |
utf8/1 | Convert string to utf8 binary. |
append(Doc1::document(), Doc2::document()) -> document()
Append two documents together
at(Label::label(), Document::document()) -> value()
Value of field in document, error if missing
doc_foldl(Fun::fun((label(), value(), A) -> A), A, Doc::document() | map()) -> A
Reduce document by applying given function to each field with result of previous field's application, starting with given initial result.
doc_foldr(Fun::fun((label(), value(), A) -> A), A, Doc::document()) -> A
Same as doc_foldl/3 except apply fields in reverse order
document(Fields::[{label(), value()}]) -> document()
Convert list of fields to a document
exclude(Labels::[label()], Document::document()) -> document()
Remove given fields from document
fields(Doc::document()) -> [{label(), value()}]
Convert document to a list of all its fields
flatten_map(Map::map()) -> map()
include(Labels::[label()], Document::document()) -> document()
Project given fields of document
lookup(Label::label(), Doc::document()) -> value() | {}
Value of field in document if there
lookup(Label::label(), Doc::document(), Default::value()) -> value()
Value of field in document if there or default
merge(UpDoc::document(), BaseDoc::document()) -> document()
First doc overrides second with new fields added at end of second doc
merge(UpDoc::document(), BaseDoc::document(), Fun::fun((label(), value(), value()) -> value())) -> document()
ms_precision(X1::unixtime()) -> unixtime()
Truncate microsecs to millisecs since bson drops microsecs anyway, so time will be equal before and after serialization.
objectid(UnixSecs::unixsecs(), MachineAndProcId::<<_:40>>, Count::integer()) -> objectid()
objectid_time(X1::objectid()) -> unixtime()
Time when object id was generated
secs_to_unixtime(UnixSecs::unixsecs()) -> unixtime()
str(CharData::unicode:chardata()) -> string()
Convert utf8 binary to string. utf8() is a subtype of unicode:chardata().
timenow() -> unixtime()
unixtime_to_secs(X1::unixtime()) -> unixsecs()
update(Label::label(), Value::value(), Document::document()) -> document()
Replace field with new value, adding to end if new
utf8(CharData::unicode:chardata()) -> utf8()
Convert string to utf8 binary. string() is a subtype of unicode:chardata().
Generated by EDoc