简体   繁体   English

从 Cloud Firestore 上的文档中获取 Collections 的名称

[英]Get the named of Collections from Document on Cloud Firestore

I want to get collections (Col01, Col02, Col03) from the document (Doc01).我想从文档 (Doc01) 中获取 collections (Col01, Col02, Col03)。 How can I approach this?我该如何处理? Check the attached image.检查附加的图像。 Thanks.谢谢。

Image图片

There is no API for getting a list of collection names that exist within your (Doc01) document.没有 API 可用于获取 (Doc01) 文档中存在的集合名称列表。 So, unfortunately, you cannot do that on Android.所以,不幸的是,你不能在 Android 上这样做。 Because you are looking for sub-collections that are nested under a document, the only option that you have is to use DocumentReference's listCollections() function but is currently available only for Node.js admin clients.因为您正在查找嵌套在文档下的子集合,所以您唯一的选择是使用 DocumentReference 的listCollections() function,但目前适用于 Node.js 管理员客户端。

The simplest solution I can think of is to create a collection with a single document, in which you should add an array that contains the names of all sub-collections that exist under your (Doc01) document.我能想到的最简单的解决方案是创建一个包含单个文档的集合,您应该在其中添加一个数组,其中包含您的 (Doc01) 文档下存在的所有子集合的名称。 To display those names is at simple as displaying the content of a List in Java.显示这些名称就像在 Java 中显示列表的内容一样简单。 This solution will work not only for Android, but for all platforms.此解决方案不仅适用于 Android,而且适用于所有平台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM