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

编程入门 行业动态 更新时间:2024-10-08 22:19:49
本文介绍了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.

更多推荐

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

本文发布于:2023-11-30 07:46:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649227.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文档   Firestore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!