def select_related(self, max_depth=1): """Handles dereferencing of :class:`~pymongo.dbref.DBRef` objects to a maximum depth in order to cut down the number queries to mongodb. .. versionadded:: 0.5 """ from dereference import dereference self._data = dereference(self._data, max_depth) return self
def __get__(self, instance, owner): """Descriptor to automatically dereference references. """ if instance is None: # Document class being used rather than a document object return self from dereference import dereference instance._data[self.name] = dereference( instance._data.get(self.name), max_depth=1, instance=instance, name=self.name, get=True ) return super(ComplexBaseField, self).__get__(instance, owner)
def select_related(self, max_depth=1): from dereference import dereference self._data = dereference(self._data, max_depth) return self