V - the type of the result values this query will producepublic abstract class StructuredQuery<V> extends Query<V>
A simple query that returns all entities for a specific kind
Query<Entity> query = Query.entityQueryBuilder().kind(kind).build();
QueryResults<Entity> results = datastore.run(query);
while (results.hasNext()) {
Entity entity = results.next();
...
}
A simple key-only query of all entities for a specific kind
Query<Key> keyOnlyQuery = Query.keyQueryBuilder().kind(KIND1).build();
QueryResults<Key> results = datastore.run(keyOnlyQuery);
...
A less trivial example of a projection query that returns the first 10 results of "age" and "name" properties (sorted and grouped by "age") with an age greater than 18
Query<ProjectionEntity> query = Query.projectionEntityQueryBuilder()
.kind(kind)
.projection(Projection.property("age"), Projection.first("name"))
.filter(PropertyFilter.gt("age", 18))
.groupBy("age")
.orderBy(OrderBy.asc("age"))
.limit(10)
.build();
QueryResults<ProjectionEntity> results = datastore.run(query);
...
| Modifier and Type | Class and Description |
|---|---|
static interface |
StructuredQuery.Builder<V>
Interface for StructuredQuery builders.
|
static class |
StructuredQuery.CompositeFilter
A class representing a filter composed of a combination of other filters.
|
static class |
StructuredQuery.Filter |
static class |
StructuredQuery.OrderBy |
static class |
StructuredQuery.PropertyFilter
A class representing a filter based on a single property or ancestor.
|
Query.ResultType<V>| Modifier and Type | Method and Description |
|---|---|
List<String> |
distinctOn() |
Cursor |
endCursor() |
boolean |
equals(Object obj) |
StructuredQuery.Filter |
filter() |
int |
hashCode() |
String |
kind() |
Integer |
limit() |
int |
offset() |
com.google.common.collect.ImmutableList<StructuredQuery.OrderBy> |
orderBy() |
List<String> |
projection() |
Cursor |
startCursor() |
abstract StructuredQuery.Builder<V> |
toBuilder() |
String |
toString() |
entityQueryBuilder, gqlQueryBuilder, gqlQueryBuilder, keyQueryBuilder, namespace, projectionEntityQueryBuilderpublic String kind()
public StructuredQuery.Filter filter()
public com.google.common.collect.ImmutableList<StructuredQuery.OrderBy> orderBy()
public Cursor startCursor()
public Cursor endCursor()
public int offset()
public Integer limit()
public abstract StructuredQuery.Builder<V> toBuilder()
Copyright © 2016 Google. All rights reserved.