Firebase中IN关键字的替代形式是什么? [英] What is the alternate of IN keyword in Firebase?

查看:62
本文介绍了Firebase中IN关键字的替代形式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firebase中的节点为:

I have my nodes in Firebase as:

users---
       |
      uid---
           |
           phone:
           name:

我正在这里寻找IN实现.我想检查数据库中是否存在电话号码列表中的哪些小肠,然后获取这些小肠.

I am looking for the IN implementation here. I want to check which enteries from a list of phone numbers are present in my database and then, fetch those enteries.

在SQL数据库中,等效查询可能是:

In SQL databases, equivlent query may be:

select phone from users where phone IN ('phone1','phone2','phone3',...)

如何在Android Firebase项目中实现这一目标?

How can I achieve this in my Android Firebase project?

推荐答案

无法复制以下SQL查询:

There is no way to replicate the following SQL query:

select phone from users where phone IN ('phone1','phone2','phone3',...)

进入Firebase实时数据库查询.相反,您可以分别在数据库中查询每个电话号码并在客户端收集结果.

into a Firebase realtime database query. What can you to instead, is to query the database for each phone number separately and collect the results client side.

如果您考虑在某个时候尝试使用 Cloud Firestore ,则可以致电 get()每个查询对象上的方法,您会看到它将返回任务反对在准备好文档后将其解决.之后,只需将所有任务收集到任务列表中,然后将该列表传递给Tasks的

If you consider at some point to try using Cloud Firestore, you can call get() method on each Query object and you'll see that it will return a Task object that it will become resolved when the document is ready. After that, simply collect all the tasks into a List of tasks, and pass that list to Tasks's whenAllComplete() method to respond when the entire set of tasks is complete. You can then check the results of all the tasks there, and take some actions accordingly.

这篇关于Firebase中IN关键字的替代形式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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