Google Firestore-什么是OR等效? [英] Google Firestore - What is OR equivalent?

查看:50
本文介绍了Google Firestore-什么是OR等效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有多个 where 的行为类似于 AND ,但是 OR 呢?

I see having mulitple where acts like AND, but how about OR?

推荐答案

您实际上无法在Cloud Firestore中执行OR查询.

You can't really do an OR query in Cloud Firestore.

作为一种解决方法,您可以运行两个单独的查询,然后在客户端上将它们合并在一起,或者添加一些自定义字段,这些字段本质上将在数据库上为您执行"OR"查询.(以后一个示例为例,如果您知道要经常在数据库上运行年龄> 65岁或18岁以下"查询,则可以创建一个特定的 age_high_or_low 字段,如果年龄字段大于65或小于18,则将设置为true.)

As a workaround, you could run two separate queries and merge them together on the client, or add some custom field that would essentially perform the "OR" query for you on the database. (For an example of that latter one, if you know you're going to often run an "age > 65 OR age < 18" query on the database, you could create a specific age_high_or_low field that you would set to true if the age field were greater than 65 or less then 18.)

这篇关于Google Firestore-什么是OR等效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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