Firestore - Get document collections

后端 未结 5 2083
谎友^
谎友^ 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:00

    firebase.initializeApp(config);
    
    const db = firebase.firestore();
    
    db.settings({timestampsInSnapshots: true});
    
    const collection = db.collection('user_dat');
    
    collection.get().then(snapshot => {
    
      snapshot.forEach(doc => {
    
        console.log( doc.data().name );    
        console.log( doc.data().mail );
    
      });
    
    });
    

提交回复
热议问题