Getting all documents from one collection in Firestore

前端 未结 8 1924
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:19

    Try following LOCs

        let query = firestore.collection('events');
        let response = [];
        await query.get().then(querySnapshot => {
              let docs = querySnapshot.docs;
              for (let doc of docs) {
                  const selectedEvent = {
                         id: doc.id,
                         item: doc.data().event
                      };
                 response.push(selectedEvent);
              }
       return response;
    

提交回复
热议问题