Ordering and limiting Firestore queries

Ordering and limiting Firestore queries

Code sample

Go

query := cities.OrderBy("name", firestore.Asc).Limit(3)
query := cities.OrderBy("name", firestore.Asc).LimitToLast(3)

Java

Query query = cities.orderBy("name").limit(3);
Query query = cities.orderBy("name").limitToLast(3);

Node.js

const firstThreeRes = await citiesRef.orderBy('name').limit(3).get();

Python

cities_ref = db.collection("cities")
query = cities_ref.order_by("name").limit_to_last(2)
results = query.get()