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)

Initializes a new BSON value from the given D type.

Members

Aliases

EmptyArray
deprecated alias EmptyArray = emptyArray

Deprecated compatibility alias.

EmptyObject
deprecated alias EmptyObject = emptyObject

Deprecated compatibility alias.

Enums

Type
enum Type

Represents the type of a BSON value

Functions

isNull
bool isNull()
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref Bson obj) del)
int opApply(int delegate(ref size_t idx, ref Bson obj) del)
int opApply(int delegate(ref string idx, ref 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)

Assigns a D type to a BSON value.

opCast
T opCast()

Converts the BSON value to a D value.

opEquals
bool opEquals(Bson other)
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
inout(T) opt(T def)

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

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.

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.

opDispatch
inout(Bson) opDispatch [@property getter]
T opDispatch [@property setter]

Allows to access existing fields of a JSON object using dot syntax.

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