问题
The documentation states:
However, if you have a filter with a range comparison (<, <=, >, >=), your first ordering must be on the same field:
That implies that I can use the non-range comparison, "==", with the orderBy clause. But this fails:
myCollectionRef.where('age', '==', 2).orderBy('name');
回答1:
If you wanted to order a query with one or more equality filters, where the ordering is by a different field, you'll need to create a composite index.
You can read more about this in our "Managing Indexes" documentation section.
来源:https://stackoverflow.com/questions/46821757/can-i-query-a-cloud-firestore-collection-with-a-where-equals-clause-and-an-order