firestore 根据一组 id 检查 id 是否存在 [英] firestore Check if id exists against an array of ids

查看:36
本文介绍了firestore 根据一组 id 检查 id 是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 firebase firestore 为我的网站开发了一个简单的聊天应用程序.每个聊天会话都有一个 id

I developing a simple chat applicaiton for my website using firebase firestore. where every chat session has an id

前提是我有一组 id

chat_sessions = [q93XhadA9QQLu6X8yfZB"、YXEYISEI8b2iixCcP3VO"、GXrSZbtrmN5NcrtvjFYp"]

我想使用以下代码获取其 id 等于 chat_sessions 对象中任何 id 的所有文档.

I want to get all document whose id is equal to any of the id's in the chat_sessions object using the code below.

return this.afs
    .collection('chats', ref => ref.where('uid','in_array',chat_sessions)).snapshotChanges...

但我没有得到任何结果.

but I am not getting any results.

我来自 PHP/MYSQL 背景相当于我想要实现的 PHP 将在 PHP 中是这样的

I come from a PHP/MYSQL background the PHP equivalent of what i am trying to achieve will be sth like this in PHP

if(in_array(uid,chat_sessions)){
      get(doc/uid)
      }

任何人都可以帮助我们根据数组中的 id 列表检查文档 id 的正确查询吗?谢谢!

can anyone help with the right query where we check for document id against a list of ids in an array? Thank You!

推荐答案

我在 firestore 上发现了其他东西,例如 "array-contains-any" 用于这种情况.

I found something else on firestore i.e "array-contains-any" for this case.

也许现在更新了.

这篇关于firestore 根据一组 id 检查 id 是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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