use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class QueryDataSnippets method createStartAtFieldQueryCursor.
/**
* Create a query defining the start point of a query.
*
* @return query
*/
Query createStartAtFieldQueryCursor() {
CollectionReference cities = db.collection("cities");
// [START fs_start_at_field_query_cursor]
// [START firestore_query_cursor_start_at_field_value_single]
Query query = cities.orderBy("population").startAt(4921000L);
// [END fs_start_at_field_query_cursor]
return query;
}
use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class QueryDataSnippets method filterNotIn.
Query filterNotIn() {
// [START fs_filter_not_in]
// [START firestore_query_filter_not_in]
CollectionReference citiesRef = db.collection("cities");
Query query = citiesRef.whereNotIn("country", Arrays.asList("USA", "Japan"));
// [END fs_filter_not_in]
return query;
}
use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class QueryDataSnippets method createSimpleQueries.
/**
* Creates queries with simple where clauses.
*
* @return queries
*/
List<Query> createSimpleQueries() {
List<Query> querys = new ArrayList<>();
CollectionReference cities = db.collection("cities");
// [START fs_simple_queries]
// [START firestore_query_filter_single_examples]
Query stateQuery = cities.whereEqualTo("state", "CA");
Query populationQuery = cities.whereLessThan("population", 1000000L);
Query nameQuery = cities.whereGreaterThanOrEqualTo("name", "San Francisco");
// [END firestore_query_filter_single_examples]
// [END fs_simple_queries]
querys.add(stateQuery);
querys.add(populationQuery);
querys.add(nameQuery);
return querys;
}
use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class QueryDataSnippets method createQuery.
/**
* Creates a sample query.
*
* @return query
*/
Query createQuery() throws Exception {
// [START fs_create_query]
// [START firestore_query_filter_eq_boolean]
// Create a reference to the cities collection
CollectionReference cities = db.collection("cities");
// Create a query against the collection.
Query query = cities.whereEqualTo("capital", true);
// retrieve query results asynchronously using query.get()
ApiFuture<QuerySnapshot> querySnapshot = query.get();
for (DocumentSnapshot document : querySnapshot.get().getDocuments()) {
System.out.println(document.getId());
}
// [END fs_create_query]
return query;
}
use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class QueryDataSnippets method createWhereWithOrderByAndLimitQuery.
/**
* Creates a query that combines where clause with order by and limit operator.
*
* @return query
*/
Query createWhereWithOrderByAndLimitQuery() {
CollectionReference cities = db.collection("cities");
// [START fs_where_order_by_limit_query]
// [START firestore_query_order_limit_field_valid]
Query query = cities.whereGreaterThan("population", 2500000L).orderBy("population").limit(2);
// [END fs_where_order_by_limit_query]
return query;
}
Aggregations