从Firestore提取文档时,我也可以在此文档中获取集合吗? [英] When fetching document from Firestore, am I also getting the collections inside this document?

查看:55
本文介绍了从Firestore提取文档时,我也可以在此文档中获取集合吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果是的话,如何获得呢?因为在进行文档参考时,您只能访问该文档的字段,而不能访问集合.

And if so, how to get it? Because when doing the document reference, you can only access the fields of that document not collections.

推荐答案

从Firestore提取文档时,我也得到了 该文档中的收藏?

When fetching document from Firestore, am I also getting the collections inside this document?

否,在提取文档时,您只会得到该文档的字段.

No, when fetching a document, you will only get the fields of this document.

如此文档中所述,使用Firestore,您可以创建浅表查询以检索文档级别的数据,而无需检索整个集合或任何嵌套的子集合". (请注意,实时数据库不是这种情况:如果获取给定节点,则也会获得所有子节点.)

As explained in this document, with Firestore, you can "create shallow queries to retrieve data at the document level without needing to retrieve the entire collection, or any nested subcollections". (Note that it is not the case with the Realtime database: if you fetch a given node, you'll get all the sub-nodes as well).

如果要访问文档的子集合,则必须

If you want to access the document's sub-collections, you have to fetch them by using their IDs. If you are using one of the Client SDKs (i.e. "mobile/web client libraries"), there is no way to query for the sub-collections IDs of a document. It means that you need to know what are the sub-collections IDs for a given document in order to fetch them (you might save the IDs of these collections in a field of their parent document).

另一方面,可以使用服务器客户端库(例如Java或Node.js库)列出文档的所有子集合,请参见

On the other hand, listing all sub-collections of a document is possible with the server client libraries, like the Java or Node.js libraries, see https://firebase.google.com/docs/firestore/query-data/get-data#list_subcollections_of_a_document

这篇关于从Firestore提取文档时,我也可以在此文档中获取集合吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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