Bson

Represents a BSON value.

struct Bson {}

Constructors

this
this(Type type, bdata_t data)

Creates a new BSON value using raw data.

this
this(double value)
this(string value, Type type)
this(Bson[string] value)
this(Bson[] value)
this(BsonBinData value)
this(BsonObjectID value)
this(bool value)
this(BsonDate value)
this(typeof(null) )
this(BsonRegex value)
this(int value)
this(BsonTimestamp value)
this(long value)
this(Json value)
this(UUID value)

Initializes a new BSON value from the given D type.

Members

Enums

Type
enum Type

Represents the type of a BSON value

Functions

byIndexValue
auto byIndexValue()

Iterates over all index/value pairs of an array.

byKeyValue
auto byKeyValue()

Iterates over all key/value pairs of an object.

byValue
auto byValue()

Iterates over all values of an object or array.

isNull
bool isNull()
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(Bson obj) del)
int opApply(int delegate(size_t idx, Bson obj) del)
int opApply(int delegate(string idx, Bson obj) del)

Allows foreach iterating over BSON objects and arrays.

opAssign
void opAssign(Bson other)
void opAssign(double value)
void opAssign(string value)
void opAssign(Bson[string] value)
void opAssign(Bson[] value)
void opAssign(BsonBinData value)
void opAssign(BsonObjectID value)
void opAssign(bool value)
void opAssign(BsonDate value)
void opAssign(typeof(null) )
void opAssign(BsonRegex value)
void opAssign(int value)
void opAssign(BsonTimestamp value)
void opAssign(long value)
void opAssign(Json value)
void opAssign(UUID value)

Assigns a D type to a BSON value.

opCast
T opCast()

Converts the BSON value to a D value.

opEquals
bool opEquals(Bson other)
opIndex
inout(Bson) opIndex(string idx)

Allows accessing fields of a BSON object using [].

opIndex
inout(Bson) opIndex(size_t idx)

Allows index based access of a BSON array value.

opIndexAssign
void opIndexAssign(T value, string idx)

Allows accessing fields of a BSON object using [].

opt
T opt(T def)
const(T) opt(const(T) def)

Returns the native type for this BSON if it matches the current runtime type.

remove
void remove(string key)

Removes an entry from a BSON obect.

toJson
Json toJson()

Converts a BSON value to a JSON value.

toString
string toString()

Returns a string representation of this BSON value in JSON format.

tryIndex
Nullable!Bson tryIndex(string key)

Check whether the BSON object contains the given key.

Properties

data
bdata_t data [@property getter]

Returns the raw data representing this BSON value (not including the field name and type).

emptyArray
Bson emptyArray [@property getter]

Returns a new, empty Bson value of type Array.

emptyObject
Bson emptyObject [@property getter]

Returns a new, empty Bson value of type Object.

get
T get [@property getter]

Converts the BSON value to a D value.

length
size_t length [@property getter]

Returns the length of a BSON value of type String, Array, Object or BinData.

type
Type type [@property getter]

Returns the BSON type of this value.

Static functions

fromJson
Bson fromJson(Json value)

Converts a given JSON value to the corresponding BSON value.

Meta