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

171
Views
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
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!