public class Query extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Query.Direction
The direction of a sort.
|
Modifier and Type | Method and Description |
---|---|
ListenerRegistration |
addSnapshotListener(EventListener<QuerySnapshot> listener)
Starts listening to this query.
|
ListenerRegistration |
addSnapshotListener(Executor executor,
EventListener<QuerySnapshot> listener)
Starts listening to this query.
|
Query |
endAt(DocumentSnapshot snapshot)
Creates and returns a new Query that ends at the provided document (inclusive).
|
Query |
endAt(Object... fieldValues)
Creates and returns a new Query that ends at the provided fields relative to the order of the
query.
|
Query |
endBefore(DocumentSnapshot snapshot)
Creates and returns a new Query that ends before the provided document (exclusive).
|
Query |
endBefore(Object... fieldValues)
Creates and returns a new Query that ends before the provided fields relative to the order of
the query.
|
boolean |
equals(Object obj)
Returns true if this Query is equal to the provided object.
|
com.google.api.core.ApiFuture<QuerySnapshot> |
get()
Executes the query and returns the results as QuerySnapshot.
|
Firestore |
getFirestore()
Gets the Firestore instance associated with this query.
|
int |
hashCode() |
Query |
limit(int limit)
Creates and returns a new Query that's additionally limited to only return up to the specified
number of documents.
|
Query |
offset(int offset)
Creates and returns a new Query that skips the first n results.
|
Query |
orderBy(FieldPath fieldPath)
Creates and returns a new Query that's additionally sorted by the specified field.
|
Query |
orderBy(FieldPath fieldPath,
Query.Direction direction)
Creates and returns a new Query that's additionally sorted by the specified field, optionally
in descending order instead of ascending.
|
Query |
orderBy(String field)
Creates and returns a new Query that's additionally sorted by the specified field.
|
Query |
orderBy(String field,
Query.Direction direction)
Creates and returns a new Query that's additionally sorted by the specified field, optionally
in descending order instead of ascending.
|
Query |
select(FieldPath... fieldPaths)
Creates and returns a new Query instance that applies a field mask to the result and returns
the specified subset of fields.
|
Query |
select(String... fields)
Creates and returns a new Query instance that applies a field mask to the result and returns
the specified subset of fields.
|
Query |
startAfter(DocumentSnapshot snapshot)
Creates and returns a new Query that starts after the provided document (exclusive).
|
Query |
startAfter(Object... fieldValues)
Creates and returns a new Query that starts after the provided fields relative to the order of
the query.
|
Query |
startAt(DocumentSnapshot snapshot)
Creates and returns a new Query that starts at the provided document (inclusive).
|
Query |
startAt(Object... fieldValues)
Creates and returns a new Query that starts at the provided fields relative to the order of the
query.
|
void |
stream(ApiStreamObserver<DocumentSnapshot> responseObserver)
Executes the query and streams the results as a StreamObserver of DocumentSnapshots.
|
Query |
whereArrayContains(FieldPath fieldPath,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field, the value must be an array, and that the array must contain the provided
value.
|
Query |
whereArrayContains(String field,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field, the value must be an array, and that the array must contain the provided
value.
|
Query |
whereEqualTo(FieldPath fieldPath,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be equal to the specified value.
|
Query |
whereEqualTo(String field,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be equal to the specified value.
|
Query |
whereGreaterThan(FieldPath fieldPath,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be greater than the specified value.
|
Query |
whereGreaterThan(String field,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be greater than the specified value.
|
Query |
whereGreaterThanOrEqualTo(FieldPath fieldPath,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be greater than or equal to the specified value.
|
Query |
whereGreaterThanOrEqualTo(String field,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be greater than or equal to the specified value.
|
Query |
whereLessThan(FieldPath fieldPath,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be less than the specified value.
|
Query |
whereLessThan(String field,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be less than the specified value.
|
Query |
whereLessThanOrEqualTo(FieldPath fieldPath,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be less or equal to the specified value.
|
Query |
whereLessThanOrEqualTo(String field,
Object value)
Creates and returns a new Query with the additional filter that documents must contain the
specified field and the value should be less or equal to the specified value.
|
@Nonnull public Firestore getFirestore()
@Nonnull public Query whereEqualTo(@Nonnull String field, @Nullable Object value)
field
- The name of the field to compare.value
- The value for comparison.@Nonnull public Query whereEqualTo(@Nonnull FieldPath fieldPath, @Nullable Object value)
fieldPath
- The path of the field to compare.value
- The value for comparison.@Nonnull public Query whereLessThan(@Nonnull String field, @Nonnull Object value)
field
- The name of the field to compare.value
- The value for comparison.@Nonnull public Query whereLessThan(@Nonnull FieldPath fieldPath, @Nonnull Object value)
fieldPath
- The path of the field to compare.value
- The value for comparison.@Nonnull public Query whereLessThanOrEqualTo(@Nonnull String field, @Nonnull Object value)
field
- The name of the field to compare.value
- The value for comparison.@Nonnull public Query whereLessThanOrEqualTo(@Nonnull FieldPath fieldPath, @Nonnull Object value)
fieldPath
- The path of the field to compare.value
- The value for comparison.@Nonnull public Query whereGreaterThan(@Nonnull String field, @Nonnull Object value)
field
- The name of the field to compare.value
- The value for comparison.@Nonnull public Query whereGreaterThan(@Nonnull FieldPath fieldPath, @Nonnull Object value)
fieldPath
- The path of the field to compare.value
- The value for comparison.@Nonnull public Query whereGreaterThanOrEqualTo(@Nonnull String field, @Nonnull Object value)
field
- The name of the field to compare.value
- The value for comparison.@Nonnull public Query whereGreaterThanOrEqualTo(@Nonnull FieldPath fieldPath, @Nonnull Object value)
fieldPath
- The path of the field to compare.value
- The value for comparison.@Nonnull public Query whereArrayContains(@Nonnull String field, @Nonnull Object value)
A Query can have only one whereArrayContains() filter.
field
- The name of the field containing an array to searchvalue
- The value that must be contained in the array@Nonnull public Query whereArrayContains(@Nonnull FieldPath fieldPath, @Nonnull Object value)
A Query can have only one whereArrayContains() filter.
fieldPath
- The path of the field containing an array to searchvalue
- The value that must be contained in the array@Nonnull public Query orderBy(@Nonnull String field)
field
- The field to sort by.@Nonnull public Query orderBy(@Nonnull FieldPath fieldPath)
fieldPath
- The field to sort by.@Nonnull public Query orderBy(@Nonnull String field, @Nonnull Query.Direction direction)
field
- The field to sort by.direction
- The direction to sort.@Nonnull public Query orderBy(@Nonnull FieldPath fieldPath, @Nonnull Query.Direction direction)
fieldPath
- The field to sort by.direction
- The direction to sort.@Nonnull public Query limit(int limit)
limit
- The maximum number of items to return.@Nonnull public Query offset(int offset)
offset
- The number of items to skip.@Nonnull public Query startAt(@Nonnull DocumentSnapshot snapshot)
snapshot
- The snapshot of the document to start at.@Nonnull public Query startAt(Object... fieldValues)
fieldValues
- The field values to start this query at, in order of the query's order by.@Nonnull public Query select(String... fields)
fields
- The fields to include.@Nonnull public Query select(FieldPath... fieldPaths)
fieldPaths
- The field paths to include.@Nonnull public Query startAfter(@Nonnull DocumentSnapshot snapshot)
snapshot
- The snapshot of the document to start after.public Query startAfter(Object... fieldValues)
fieldValues
- The field values to start this query after, in order of the query's order
by.@Nonnull public Query endBefore(@Nonnull DocumentSnapshot snapshot)
snapshot
- The snapshot of the document to end before.@Nonnull public Query endBefore(Object... fieldValues)
fieldValues
- The field values to end this query before, in order of the query's order by.@Nonnull public Query endAt(Object... fieldValues)
fieldValues
- The field values to end this query at, in order of the query's order by.@Nonnull public Query endAt(@Nonnull DocumentSnapshot snapshot)
snapshot
- The snapshot of the document to end at.public void stream(@Nonnull ApiStreamObserver<DocumentSnapshot> responseObserver)
responseObserver
- The observer to be notified when results arrive.@Nonnull public com.google.api.core.ApiFuture<QuerySnapshot> get()
@Nonnull public ListenerRegistration addSnapshotListener(@Nonnull EventListener<QuerySnapshot> listener)
listener
- The event listener that will be called with the snapshots.@Nonnull public ListenerRegistration addSnapshotListener(@Nonnull Executor executor, @Nonnull EventListener<QuerySnapshot> listener)
executor
- The executor to use to call the listener.listener
- The event listener that will be called with the snapshots.public boolean equals(Object obj)
Copyright © 2019 Google LLC. All rights reserved.