dbref – Tools for manipulating DBRefs (references to documents stored in MongoDB)

Tools for manipulating DBRefs (references to MongoDB documents).

class pymongo.dbref.DBRef(collection, id, database=None)

Initialize a new DBRef.

Raises TypeError if collection or database is not an instance of basestring. database is optional and allows references to documents to work across databases.

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

New in version 1.1.1: The database parameter.

See general MongoDB documentation

dbrefs

as_doc()

Get the SON document representation of this DBRef.

Generally not needed by application developers

collection
Get the name of this DBRef’s collection as unicode.
database

Get the name of this DBRef’s database.

Returns None if this DBRef doesn’t specify a database.

New in version 1.1.1.

id
Get this DBRef’s _id.

Previous topic

code – Tools for representing JavaScript code to be evaluated by MongoDB

Next topic

binary – Tools for representing binary data to be stored in MongoDB

This Page