问题
I want to have a query like
db.collection("Bookings")
.whereField("servicer", isEqualTo: userID || "customer", isEqualTo: userID)
Instead of having two different reads it will just have one, and it gets all the documents that servicer == userID and customer == userID.
回答1:
This is not possible with a single query - there is no logical OR operation that works across multiple fields in a document. You will need to have two queries, one for "servicer", and another for "customer", then merge the results of those queries on the client.
来源:https://stackoverflow.com/questions/59547767/is-it-possible-to-have-either-or-wherefields-for-firestore-query