'Firebase Firestore Query v9 Works "desc" but not "asc" (indexed both)
I am trying to order by price in both directions. However, it currently only works "desc" and not "asc".
The 'direction' variable is either set to "asc" or "desc" depending on button click. I have checked - it is definitely asc or desc.
The request returns 50 items on "desc" but returns an empty array on "asc". Surely this doesn't make sense as it is the same request reading the same data just in another direction.
const reference = await query(
collection(firestore, "assets"),
where("status.locked", "==", true),
orderBy("status.price", direction),
limit(count),
startAfter(lastVisible?.status?.price ?? "")
);
This is how direction is initialised: (filtering either is "High to Low" or "Low to High")
let direction = filtering === "High to Low" ? "desc" : "asc";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
