14.1Class BSON

Represents a BSON object.

Class BSON( [param] )
param An integer (reserved space for internal buffer) or a dict to append.

If no dict is given, an "empty" bson object is created.

Methods
appendAppend some data to the BSON object
asDictReturn a dictionary representing the BSON object.
genOIDGenerate and append an OID.
hasKeyChecks if the collection contains the required key.
resetClear the BSON object, making it an "empty" one.
valueGet the value for a given key.

Methods

append

Append some data to the BSON object

BSON.append( dict )
dict A dict (with keys that must be strings...)
Returnself

Example:


        import from mongo
        obj = mongo.BSON().genOID().append( [ "key" => "value" ] )

asDict

Return a dictionary representing the BSON object.

BSON.asDict()
ReturnA dictionary

genOID

Generate and append an OID.

BSON.genOID( [name] )
name Key name (default "_id")
Returnself

hasKey

Checks if the collection contains the required key.

BSON.hasKey( key )
key
Returntrue if BSON has that key

reset

Clear the BSON object, making it an "empty" one.

BSON.reset( [bytes] )
bytes Reserve some space for internal buffer.

value

Get the value for a given key.

BSON.value( key )
key The researched key.
Returnvalue for key given (might be nil!), or nil if not found.
Made with http://www.falconpl.org