说我有这种结构
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.