Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

295
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda