如何在Cloud Firestore中完成WHERE IN查询 [英] How to accomplish WHERE IN query in Cloud Firestore

查看:97
本文介绍了如何在Cloud Firestore中完成WHERE IN查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据值是否在我有客户端的数组中找出如何返回查询.到目前为止,我对此事一无所获.这可能吗?

I have tried to figure out how to return a query based on whether the values are in an array I have client side. I so far have found nothing regarding the issue. Is this possible?

推荐答案

Firestore现在支持"IN"查询: 公告 文档

Firestore now supports "IN" queries: Announcement Documentation

示例:

let citiesRef = db.collection("cities")

citiesRef.whereField("country", in: ["USA", "Japan"])

2019年11月之前

在Firestore中,没有像SQL那样习惯的位置".

Before November 2019

In Firestore, there is no "where in" like you might be used to with SQL.

如果知道要查询的值,请对每个查询执行不同的查询,然后调用

If you know the values you want to query, perform different queries for each one, and call getDocument() on each of the DocumentReference objects. You typically would do this in a loop an collect the results yourself.

这篇关于如何在Cloud Firestore中完成WHERE IN查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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