应用类似SQL的联接以从多个集合中获取数据-Firestore [英] Apply join like SQL to get data from multiple collections - Firestore

查看:38
本文介绍了应用类似SQL的联接以从多个集合中获取数据-Firestore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firestore上设置了项目数据库.在某些情况下,我只想从多个集合中提取数据并像SQL那样将它们组合在一起.此外,我们还提供了分页功能,其中滤镜应用于数据.因此,就像在何处应用条件并加入多个集合以获取相关数据一样.有人可以帮我得到这个结果吗?

I have a project database setup on Firestore. For some case I just want to pull out data from multiple collections and combine them like SQL. Also we have provision of pagination with filters applied on data. So its like applying where condition and joining multiple collections to get relevant data. Can anybody help me to get this result?

推荐答案

Firestore读取操作从单个集合或一组具有相同名称的集合中获取文档.它不支持服务器端联接操作.

Firestore read operations get documents from a single collection, or a group of collections of the same name. It has no support for server-side join operations.

两个常见的解决方法是:

The two common workaround for this are:

  1. 从您的应用程序代码(也称为客户端联接)中加载其他数据.这会稍微影响性能,但并没有您预期的那么大-因此,在排除性能之前,一定要尝试衡量性能.
  2. 从辅助集合中复制所需的数据.这样,您可以存储更多数据,并且写操作变得更加复杂,但是读取数据既快速又简单.

第二种解决方案也是对两个集合中的数据都加条件的唯一方法,因为也无法跨集合进行查询.

The second solution is also the only way to have conditions on the data from both collections, as there's also no way to query across collections.

如果您来自关系数据库的背景,这可能是非常意外的,但它实际上在NoSQL解决方案中非常普遍,这也是它们可以很好地扩展到海量数据大小的原因之一.

While this may all be very unexpected if you come from a background in relational databases, it is actually very common amongst NoSQL solutions and is one of the reasons they can scale so well to massive data sizes.

要了解更多信息,我强烈建议阅读 NoSQL数据并观看了解Cloud Firestore .

To learn more, I highly recommend reading NoSQL data modeling and watching Getting to know Cloud Firestore.

这篇关于应用类似SQL的联接以从多个集合中获取数据-Firestore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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