Ordering a Firestore query with a filter

Ordering a Firestore query with a filter

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample

Go

query := cities.Where("population", ">", 2500000).OrderBy("population", firestore.Asc)

Node.js

citiesRef.where('population', '>', 2500000).orderBy('population');

PHP

$query = $citiesRef
    ->where('population', '>', 2500000)
    ->orderBy('population');

Python

cities_ref = db.collection(u'cities')
query = cities_ref.where(
    u'population', u'>', 2500000).order_by(u'population')
results = query.stream()

Ruby

query = cities_ref.where("population", ">", 2_500_000).order("population")

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.