简体   繁体   中英

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.

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());
                     });
              });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM