最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Firestore获取根集合的所有文档和子集合

SEO心得admin44浏览0评论
本文介绍了Firestore获取根集合的所有文档和子集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

说我有这种结构

A (collection): { a (doc): { name:'Tim', B (collection):{ b (doc): { color:'blue' } } } }

其中A和B是集合,而a和b是文档. 是否有一种方法可以通过一个查询获取根文档中包含的所有内容? 如果我这样查询

where A and B are collections while a and b are documents. Is there a way to get everything contained in a root document with one query? If I query like this

db.collection("A").doc("a").get()

我刚得到name:'Tim'字段.我想要的是也获取所有B的文件. 我基本上希望我的查询返回

I just gets name:'Tim' field. What I want is to also get all B's documents. I basically wish my query returns

{ user:'Tim', B (collection):{ b (doc): { color:'blue' } } }

是可能还是真的需要针对每个集合进行多个查询:/?

Is it possibly or do I really need to make multiple queries one for each collection :/ ?

说我有一个非常深的嵌套的表示用户个人资料的集合树,由于每次加载用户个人资料时,我都有一个读取请求的乘数,因此我的成本会像地狱般上升.1 x N其中N是我的树的深度:/.

Say I have a really deep nested tree of collections representing the user profile, my costs will raise like hell since each time I load a user profile I have a multiplier of read requests 1 x N where N is the depth of my tree :/.

推荐答案

众所周知,默认情况下,Cloud Firestore中的查询是浅层的.虽然将来Google会考虑使用这种查询,但不支持这种查询.

As we know querying in Cloud Firestore is shallow by default. This type of query isn't supported, although it is something Google may consider in the future.

发布评论

评论列表(0)

  1. 暂无评论