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.newEntityQueryBuilder().setKind(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.newKeyQueryBuilder().setKind(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.newProjectionEntityQueryBuilder()
.setKind(kind)
.setProjection(Projection.property("age"), Projection.first("name"))
.setFilter(PropertyFilter.gt("age", 18))
.setGroupBy("age")
.setOrderBy(OrderBy.asc("age"))
.setLimit(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 |
---|---|
boolean |
equals(Object obj) |
List<String> |
getDistinctOn()
Returns the distinct on clause for this query.
|
Cursor |
getEndCursor()
Returns the end cursor for this query.
|
StructuredQuery.Filter |
getFilter()
Returns the filter for this query.
|
String |
getKind()
Returns the kind for this query.
|
Integer |
getLimit()
Returns the limit for this query.
|
int |
getOffset()
Returns the offset for this query.
|
List<StructuredQuery.OrderBy> |
getOrderBy()
Returns the order by clause for this query.
|
List<String> |
getProjection()
Returns the projection for this query.
|
Cursor |
getStartCursor()
Returns the start cursor for this query.
|
int |
hashCode() |
abstract StructuredQuery.Builder<V> |
toBuilder() |
String |
toString() |
getNamespace, newEntityQueryBuilder, newGqlQueryBuilder, newGqlQueryBuilder, newKeyQueryBuilder, newProjectionEntityQueryBuilder
public String getKind()
public StructuredQuery.Filter getFilter()
public List<StructuredQuery.OrderBy> getOrderBy()
public Cursor getStartCursor()
public Cursor getEndCursor()
public int getOffset()
public Integer getLimit()
public abstract StructuredQuery.Builder<V> toBuilder()
Copyright © 2019 Google LLC. All rights reserved.