I have the following typescript for looking up a city based on its population...
import { getFirebase } from "react-redux-firebase";
...
get fb() {
return getFirebase();
}
get fs() {
return this.fb.firestore();
}
getCollection(collectionName: string) {
return this.fs.collection(collectionName);
}
...
firestore.collection("cities").where("population", "<", 100000)
What if I wanted to add a clause to look up a city by its population AND restrict the state to California? (My state column is called "CA")?
If you're working with the data as shown in the documentation on compound queries , then just add another where clause, which creates a logical AND condition:
firestore
.collection("cities")
.where("population", "<", 100000)
.where("state", "==", "CA")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.