I am using Firestore and I have very simple queries with equality filter where I am required to do orderBy (because I have to limit the results). I can't use startAfter withour orderBy, because Firebase throws an error in that case.
FirebaseError: Too many arguments provided to Query.startAfter(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses
However, I can't use orderBy with an equality filter. Example:
query.where('tags.supporter', '==', true).orderBy('tags.supporter');
This throws a Firebase error:
FirebaseError: Order by clause cannot contain a field with an equality filter tags.supporter
Funny enough, this works just fine :-
query.where('tags.supporter', '<=', true).where('tags.supporter', '>=', true)
^ this works and gives me tags.supporter == true, but I can't use it with multiple filters.
Example:
query.where('tags.supporter', '==', true).where('tags.volunteer', '==', true)
^ works, but I can't use startAfter without orderBy. But if I try to use orderBy, I get the error :-
query.where('tags.supporter', '==', true).where('tags.volunteer', '==', true).orderBy(...)
^ doesn't work!
I can't do the <= >= hack because it requires composite index but I can't set that up because these are user-added tags.
Any ideas?
If this truly is a limitation then it should be mentioned explicitly in the documentation because it would have influenced my decision. Now I'll have to either build a lot of logic in my own app to filter results if this truly is a limitation.