Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
How to Read the data from a sub collection from firestore database in React

I'm creating a Firebase project and I have a collection with a nested collection. I have tried to perform CRUD operations in the parent collection but I have no idea how to get the document data from the nested array.

Here is what my firestore database looks like: enter image description here

and here is the code that I wrote for reading and creating a document in the parent child:

    const addEntry = () => {
    try {
        const docRef = firestore.addDoc(firestore.collection(db, "quiz"), {
            question: "How many sides are equal in a scalene triangle?",
            question_no: 1,
        });
        console.log("Document written with ID: ", docRef.id);
    } catch (e) {
        console.error("Error adding document: ", e);
    }
};
const getData = () => {
    firestore
        .getDocs(firestore.collection(db, "quiz"))
        .then((querySnapshot) => {
            querySnapshot.forEach((doc) => {
                console.log(`${doc.id} => ${doc.data()}`);
            });
        });
};

How can I get the data from the sub-collection or the nested collection.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!