如何在Cloud Firestore中使用逻辑或执行复合查询? [英] How to perform compound queries with logical OR in Cloud Firestore?

查看:104
本文介绍了如何在Cloud Firestore中使用逻辑或执行复合查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过文档


您还可以链接多个where()方法来创建更具体的查询(逻辑AND)。 b
$ b

如何执行查询?
示例:


  1. 给我所有 status 字段的文件打开即将发布

  2. $ c> status == open OR createdAt< =


解决方案 OR不支持,因为服务器难以扩展它(需要保持状态去重)。解决方法是发出2个查询,每个条件一个,并在客户端进行重复数据删除。


From the docs:

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

How can I perform an OR query? Example:

  1. Give me all documents where the field status is open OR upcoming
  2. Give me all documents where the field status == open OR createdAt <= <somedatetime>

解决方案

OR isn't supported as it's hard for the server to scale it (requires keeping state to dedup). The work around is to issue 2 queries, one for each condition, and dedup on the client.

这篇关于如何在Cloud Firestore中使用逻辑或执行复合查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆