Getting all documents from one collection in Firestore

前端 未结 8 1919
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:28

    Here's a simple version of the top answer, but going into an object with the document ids:

    async getMarker() {
        const snapshot = await firebase.firestore().collection('events').get()
        return snapshot.docs.reduce(function (acc, doc, i) {
                  acc[doc.id] = doc.data();
                  return acc;
                }, {});
    }
    

提交回复
热议问题