Firebase如何使用子集合过滤集合 [英] Firebase how to filter collection with a sub collection

查看:45
本文介绍了Firebase如何使用子集合过滤集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为帖子"的收藏集.帖子具有称为反馈"的子集合.

I have a collection called "posts". Posts has sub collection called "feedback".

当用户向帖子提供反馈时,其ID和评论会添加到反馈子集合中.

when a user give feedback to a post his id and comment get added to feedback sub collection.

现在,我想查找用户未提供反馈的帖子.

Now I want to find posts that user has not given a feedback.

类似下面的SQL查询

select * from posts where userId not in (select userId from feedback)

有人可以提供有关此操作的建议吗?

Can someone provide advice on how to do this?

推荐答案

Firestore不支持集合或子查询之间的联接.您将无法执行使用多个集合中数据的任何查询.

Firestore doesn't support joins between collections or subqueries. You won't be able to perform any queries that use data from more than one collection.

此外,Firestore不支持查询不存在.因此,您将无法查询字段中是否缺少数据.Firestore要求所有查询都必须使用高性能索引,该索引只能跟踪文档中存在的数据.

Also, querying for non-existence isn't supported by Firestore. So, you won't be able to query for the absence of data in a field. Firestore requires that all queries be able to use a highly performant index, which only tracks data present in documents.

这篇关于Firebase如何使用子集合过滤集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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