Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

71
Views
I'm trying to read a field of all Documents at the same time but I'm only getting the field of first document

I'm trying to get the field items(array) of all my documents Orders, but I can only get one of my documents field at a time. I want it to show the whole Order detail as well.

Output i get Firestore database

Here is the code I have:

function receiptData() {

    document.getElementById("pro").innerHTML = "";
    firebase
        .firestore()
        .collection("orders")
        .get()
        .then((querySnapshot) => {

            querySnapshot.forEach((doc) => {

                console.log(doc.id, " => ", doc.data());

                var data = doc.id;

                for (let i = 0; i < doc.id.length; i++) {


                    let row = `<tr>
                            <td><a>${(doc.data().items[i]["productname"])}</a></td>
                            <td><a>${(doc.data().items[i]["cart_quantity"])}</a></td>
                            <td class="text-danger"> <a>${doc.data().total_amount}</a> <i class="mdi mdi-arrow-down"></i>
                            </td>
                            <td>
                                <label class="badge badge-danger"><a></a></label>
                            </td>
                            </tr>`;

                    document.getElementById("pro").innerHTML += row;
            }

        });
    });
}
7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.