且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Firestore-获取文档集合

更新时间:2023-02-14 09:41:11

如果使用的是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.