Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda