![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | is_keys_only |
def | projection |
def | is_distinct |
def | filter |
def | order |
def | ancestor |
![]() | |
def | __init__ |
def | is_keys_only |
def | projection |
def | is_distinct |
def | run |
def | __iter__ |
def | __getstate__ |
def | get |
def | count |
def | fetch |
def | index_list |
def | cursor |
def | with_cursor |
def | __getitem__ |
A Query instance queries over instances of Models. You construct a query with a model class, like this: class Story(db.Model): title = db.StringProperty() date = db.DateTimeProperty() query = Query(Story) You modify a query with filters and orders like this: query.filter('title =', 'Foo') query.order('-date') query.ancestor(key_or_model_instance) Every query can return an iterator, so you access the results of a query by iterating over it: for story in query: print story.title For convenience, all of the filtering and ordering methods return "self", so the easiest way to use the query interface is to cascade all filters and orders in the iterator line like this: for story in Query(story).filter('title =', 'Foo').order('-date'): print story.title
def google.appengine.ext.db.Query.__init__ | ( | self, | |
model_class = None , |
|||
keys_only = False , |
|||
cursor = None , |
|||
namespace = None , |
|||
_app = None , |
|||
distinct = False , |
|||
projection = None |
|||
) |
Constructs a query over instances of the given Model. Args: model_class: Model class to build query for. keys_only: Whether the query should return full entities or only keys. projection: A tuple of strings representing the property names to include in the projection this query should produce or None. Setting a projection is similar to specifying 'SELECT prop1, prop2, ...' in SQL. See _BaseQuery.projection for details on projection queries. distinct: A boolean, true if the projection should be distinct. See _BaseQuery.is_distinct for details on distinct queries. cursor: A compiled query from which to resume. namespace: The namespace to use for this query.
def google.appengine.ext.db.Query.ancestor | ( | self, | |
ancestor | |||
) |
Sets an ancestor for this query. This restricts the query to only return results that descend from a given model instance. In other words, all of the results will have the ancestor as their parent, or parent's parent, etc. The ancestor itself is also a possible result! Args: ancestor: Model or Key (that has already been saved) Returns: Self to support method chaining. Raises: TypeError if the argument isn't a Key or Model; NotSavedError if it is, but isn't saved yet.
def google.appengine.ext.db.Query.filter | ( | self, | |
property_operator, | |||
value | |||
) |
Add filter to query. Args: property_operator: string with the property and operator to filter by. value: the filter value. Returns: Self to support method chaining. Raises: PropertyError if invalid property is provided.
def google.appengine.ext.db.Query.order | ( | self, | |
property | |||
) |
Set order of query result. To use descending order, prepend '-' (minus) to the property name, e.g., '-date' rather than 'date'. Args: property: Property to sort on. Returns: Self to support method chaining. Raises: PropertyError if invalid property is provided.