Explore Related Tools
Hand-picked utilities and calculators related to this tool.
Firestore provides powerful query capabilities to retrieve specific documents from a collection or collection group.
Use the query function along with where filters.
import { db } from "../lib/firebase";
import { collection, query, where, getDocs } from "firebase/firestore";
const q = query(collection(db, "cities"), where("capital", "==", true));
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
});== : Equal to!= : Not equal to< : Less than<= : Less than or equal to> : Greater than>= : Greater than or equal toarray-contains : Matches if an array contains a specific valuein / not-in : Matches if the field is in a list of valuesimport { orderBy, limit } from "firebase/firestore";
const q = query(
collection(db, "cities"),
orderBy("name"),
limit(3)
);You can chain multiple where filters together.
const q = query(
collection(db, "cities"),
where("state", "==", "CA"),
where("population", ">", 1000000)
);Hand-picked utilities and calculators related to this tool.
