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=None, **kwargs)¶
Initialize a new
DBRef
.Raises
TypeError
if collection or database is not an instance ofstr
. database is optional and allows references to documents to work across databases. Any additional keyword arguments will create additional fields in the resultant embedded document.- Parameters:
collection (str) – name of the collection the document is stored in
id (Any) – the value of the document’s
"_id"
fielddatabase (Optional[str]) – name of the database to reference
kwargs (Any) – additional keyword arguments will create additional, custom fields
_extra (Optional[Mapping[str, Any]]) –
See also
The MongoDB documentation on dbrefs.
- as_doc()¶
Get the SON document representation of this DBRef.
Generally not needed by application developers