Getting all documents from one collection in Firestore

前端 未结 8 1941
Happy的楠姐
Happy的楠姐 2020-12-23 15:59

Hi I\'m starting with javascript and react-native and I\'m trying to figure out this problem for hours now. Can someone explain me how to get all the documents from firestor

8条回答
  •  清歌不尽
    2020-12-23 16:34

    I made it work this way:

    async getMarkers() {
      const markers = [];
      await firebase.firestore().collection('events').get()
        .then(querySnapshot => {
          querySnapshot.docs.forEach(doc => {
          markers.push(doc.data());
        });
      });
      return markers;
    }
    

提交回复
热议问题