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 | |
append | Append some data to the BSON object |
asDict | Return a dictionary representing the BSON object. |
genOID | Generate and append an OID. |
hasKey | Checks if the collection contains the required key. |
reset | Clear the BSON object, making it an "empty" one. |
value | Get the value for a given key. |
Append some data to the BSON object
BSON.append( dict )
dict | A dict (with keys that must be strings...) |
Return | self |
Example:
import from mongo obj = mongo.BSON().genOID().append( [ "key" => "value" ] )
Return a dictionary representing the BSON object.
BSON.asDict()
Return | A dictionary |
Generate and append an OID.
BSON.genOID( [name] )
name | Key name (default "_id") |
Return | self |
Checks if the collection contains the required key.
BSON.hasKey( key )
key | |
Return | true if BSON has that key |
Clear the BSON object, making it an "empty" one.
BSON.reset( [bytes] )
bytes | Reserve some space for internal buffer. |
Get the value for a given key.
BSON.value( key )
key | The researched key. |
Return | value for key given (might be nil!), or nil if not found. |