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

173
Visualizações
forEach() function not firing on Google Cloud Firestore query

I'm working on creating a Firestore database hosted through a web application. I want to query all the docs in my "tasks" collection and grab the ones that aren't labeled extra who have the "dept" field value of "MUSH".

Here is an excerpt of my code:

import { initializeApp } from "firebase/app";
import { getFirestore,
         collection,
         getDocs,
         query,
         where
       } from 'firebase/firestore';

const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

const mush = query(collection(db, "tasks"), where("extra", "!=", "true"), where("dept", "==", "MUSH"));

const mushList = [];
const innerMushList = [];
const weekdayList = []

try {
  const mushSnapshot = await getDocs(mush);
  console.log("checkpoint 1");
  mushSnapshot.forEach((doc) => {
    console.log("checkpoint 2");
    const task = doc.get("task");
    innerMushList.push(task);
    if (doc.get("monday") != null) {
      weekdayList.push("Mon");
    }
    else if (doc.get("tuesday") != null) {
      weekdayList.push("Tue");
    }
    else if (doc.get("wednesday") != null) {
      weekdayList.push("Wed");
    }
    else if (doc.get("thursday") != null) {
      weekdayList.push("Thu");
    }
    else if (doc.get("friday") != null) {
      weekdayList.push("Fri");
    }
    else {}
    innerMushList.push(weekdayList);
    weekdayList = [];
    const time = doc.get("time");
    innerMushList.push(time);
    const staff = doc.get("staff");
    innerMushList.push(staff);
    mushList.push(innerMushList);
    innerMushList = [];
  });
}
catch(error) {
  console.log(error);
}

When I run the code in my browser, "checkpoint 1" appears in my console. "Checkpoint 2", however, doesn't appear at all. The console doesn't present me with any errors. Any ideas on how to fix this? When I run console.log(mushSnapshot) in the place of checkpoint 1, the console prints out an object that is labeled "Mh". Please see the picture attached.

console output

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