Is it possible to have either or whereFields for Firestore query?

别来无恙 提交于 2020-07-03 10:06:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!