dbref – Tools for manipulating DBRefs (references to documents stored in MongoDB)
Tools for manipulating DBRefs (references to MongoDB documents).
- class
bson.dbref.
DBRef
(collection, id, database=None, _extra={}, **kwargs) - Initialize a new
DBRef
.
Raises TypeError
if collection or database is notan instance of basestring
(str
in python 3).database is optional and allows references to documents to workacross databases. Any additional keyword arguments will createadditional fields in the resultant embedded document.
Parameters:
- collection: name of the collection the document is stored in
- id: the value of the document’s
"_id"
field - database (optional): name of the database to reference
- **kwargs (optional): additional keyword arguments willcreate additional, custom fields
See also
The MongoDB documentation on
Generally not needed by application developers
collection
Get the name of this DBRef’s collection as unicode.
- Get the name of this DBRef’s database.
Returns None if this DBRef doesn’t specify a database.