dbref
– Tools for manipulating DBRefs (references to documents stored in MongoDB)¶
Tools for manipulating DBRefs (references to MongoDB documents).
- class bson.dbref.DBRef(collection: str, id: Any, database: Optional[str] = None, _extra: Optional[Mapping[str, Any]] = None, **kwargs: Any)¶
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: name of the collection the document is stored in
id: the value of the document’s
"_id"
fielddatabase (optional): name of the database to reference
**kwargs (optional): additional keyword arguments will create additional, custom fields
See also
The MongoDB documentation on dbrefs.
- as_doc() SON[str, Any] ¶
Get the SON document representation of this DBRef.
Generally not needed by application developers
- property collection: str¶
Get the name of this DBRef’s collection.
- property database: Optional[str]¶
Get the name of this DBRef’s database.
Returns None if this DBRef doesn’t specify a database.
- property id: Any¶
Get this DBRef’s _id.