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 | Changes the value for a given key, or inserts a new 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. |
Changes the value for a given key, or inserts a new key.
BSON.value( key )
| key | The key of which the value should be changed or inserted. |
| Return | value for key given (might be nil), or nil. |