Firestore - Get document collections

后端 未结 5 2048
谎友^
谎友^ 2020-12-28 21:32

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 ava

5条回答
  •  無奈伤痛
    2020-12-28 22:02

    Update
    API has been updated, now function is .listCollections() https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#listCollections


    getCollections() method is available for NodeJS.

    Sample code:

        db.collection("Collection").doc("Document").getCollections().then((querySnapshot) => {
        querySnapshot.forEach((collection) => {
            console.log("collection: " + collection.id);
            });
        });
    

提交回复
热议问题