I’m trying to make a Firestore query to get all my incoming meetings. Some meetings have a date
, and some don’t (they will be scheduled later). Here’s my current query:
query(
collection,
orderBy('date'),
or(where('date', '==', null), where('date', '>=', new Date()))
);
However, when I run this query, I get the error:
Order by clause cannot contain a field with an equality filter date
I understand this error in certain cases, but I have an OR
condition that is supposed to handle both cases.
To provide some additional context, I’m using Cloud Firestore and a front-end client to query the database. I’ve tried using different approaches and queries, but I haven’t been able to find a solution.
I’ve also checked the Firestore documentation and other resources for help, but I suspect this may be a bug.
If anyone has any ideas on how to order the results by date while still including meetings without a date, I would greatly appreciate it.
Thank you.
2
Answers
Why Dont you get the two seperate like
mind the syntax is not correct im on typescript just want to get the point in
then sort them locally
From the list of query limitations in the Firestore documentation:
I’m actually not sure why this limitation exists, so I’m gonna ask around – but it doesn’t seem to be a bug as you expect.
Would it be possible to rewrite the query to use
!=
instead of==
?And in fact, it might already work with just that last condition as
null
is not an actual date value: