Firestore-获取文档集合 [英] Firestore - Get document collections

查看:72
本文介绍了Firestore-获取文档集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会自动执行Firestore数据库的备份过程.想法是循环遍历根文档以构建JSON树. 但是我没有找到一种方法来获取文档的所有集合.我想这是有可能的,因为在Firestore控制台中我们可以看到树. 有什么想法吗?

解决方案

如果使用的是Node.js服务器SDK,则可以在DocumentReference上使用getCollections()方法: https://cloud.google.com/nodejs/docs /reference/firestore/0.8.x/DocumentReference#getCollections

此方法将返回一个CollectionReference对象数组的承诺,可用于访问集合中的文档.

i would to automate backup process of a firestore database. The idea is to loop over root document to build a JSON tree. but i didn't find a way to get all collections available for a document. I guess it's possible as in firestore console we can see the tree. Any ideas ?

解决方案

If you are using the Node.js server SDK you can use the getCollections() method on DocumentReference: https://cloud.google.com/nodejs/docs/reference/firestore/0.8.x/DocumentReference#getCollections

This method will return a promise for an array of CollectionReference objects which you can use to access the documents within the collections.

这篇关于Firestore-获取文档集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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