SShah
SShah

Reputation: 263

How can i get multiple documents from the firestore

Hi I want to get multiple documents from the firestore.

var docBookingRef = firestore().collection('timeSlot');
docData.forEach((item) => {
    docBookingRef.where('docId', '==', item);
});
docBookingRef.get().then((doc) => {
    doc.forEach(function(docV) {
        console.log("Slot data", docV.data());

    });
})

docData contains ids of all list. I am not getting any list from the above code.

Upvotes: 1

Views: 1620

Answers (1)

I have barely used React and never used Firebase, but after using a where you might inmediately want to use the get() (where returns a new query object and the get() retrieves the info, as Frank van Puffelen clarified)

docData.forEach((item)=>{
   firestore().collection('timeSlot')
              .where('docId','==', item)
              .get()
              .then(function(doc) {
                     doc.forEach(function(docV) {
                         console.log("Slot data", docV.data());
                     });
              });
});

Upvotes: 2

Related Questions