def make_directed_query(self, kind_class, keys_only=False):
"""Construct a query for this key range, including the scan direction.
Args:
kind_class: A kind implementation class (a subclass of either
db.Model or ndb.Model).
keys_only: bool, default False, use keys_only on Query?
Returns:
A db.Query or ndb.Query instance (corresponding to kind_class).
Raises:
KeyRangeError: if self.direction is not in (KeyRange.ASC, KeyRange.DESC).
"""
if ndb is not None:
if issubclass(kind_class, ndb.Model):
return self.make_directed_ndb_query(kind_class, keys_only=keys_only)
assert self._app is None, '_app is not supported for db.Query'
direction = self.__get_direction("", "-")
query = db.Query(kind_class, namespace=self.namespace, keys_only=keys_only)
query.order("%s__key__" % direction)
query = self.filter_query(query)
return query
评论列表
文章目录