database - 如何在 Cloud Firestore 中使用逻辑 OR 执行复合查询?

标签 database firebase google-cloud-platform google-cloud-firestore

来自 the docs :

You can also chain multiple where() methods to create more specific queries (logical AND).



我如何执行 OR询问?
例子:
  • 给我所有文件所在字段statusopenupcoming
  • 给我所有文件所在字段status == opencreatedAt <= <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/

    相关文章:

    java - 将 Json 转换为列表

    SQL Server 存储过程从数据库备份文件恢复

    database - 池连接超时

    SQL 可移植性陷阱

    node.js - 是否可以在 Firebase 托管上托管 Express 和 socket.io 应用程序?

    django - 如何使用 Django 检查 firebase 数据库中的 child 是否存在?

    ios - 尽管初始化成功,但 iOS 的 Firebase 崩溃报告不会发送崩溃

    cloud - GCP 启动脚本执行位置

    hadoop - 自动设置 Dataproc 集群后,Yarn/Spark 的内存分配不正确

    java - 如何从 Java 中的 Cloud Function 触发 Cloud Dataflow 管道作业?