来自 the docs :
You can also chain multiple where() methods to create more specific queries (logical AND).
我如何执行
OR
询问?例子:
status
是 open
或 upcoming
status == open
或 createdAt <= <somedatetime>
最佳答案
OR
不受支持,因为服务器很难对其进行扩展(需要将状态保持为重复数据删除)。解决方法是发出 2 个查询,每个条件一个,并在客户端上进行重复数据删除。
编辑(2019 年 11 月):
Cloud Firestore 现在支持 IN
查询是有限类型的 OR
询问。
对于上面的示例,您可以执行以下操作:
// Get all documents in 'foo' where status is open or upcmoming
db.collection('foo').where('status','in',['open','upcoming']).get()
然而,仍然无法做一个通用的
OR
条件涉及多个领域。
关于database - 如何在 Cloud Firestore 中使用逻辑 OR 执行复合查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55594384/