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

147
Views
How can I read data from firestore database in a schedule function?

I'm new to Firebase and I'm blocked on something. Actually, I've some difficulties reading data from a Firestore Database. My code:

const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();

exports.scheduledFunction = functions.pubsub.schedule("* * * * *").onRun(async () => {
  console.log("start");
  const querySnapshot = await db.collection("Next_callenges").get();
  console.log("Let's see :", querySnapshot);
  return null;
});

There is no output except this : "let's see : QuerySnapshot{".

To add some context, the objective behind this code is to get the first data inserted in the first database, add it to a second database and delete it from the first one.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As others have commented, the output you get is exactly what is expected from your code: since you log querySnapshot, you get whatever debug output the QuerySnapshot class defines.

If you want to see the data of each document in that query snapshot, you can do:

querySnapshot.forEach((doc) => {
  console.log("Document "+doc.id+":", doc.data());
})

Note that this is just using the Firestore API and has nothing to do with the fact that you use Firestore in Cloud Functions. Since Cloud Functions adds quite some complexity to the case, I'd recommend first learning more about the Firestore API in JavaScript by reading its documentation and following its codelab.

about 4 years ago · Juan Pablo Isaza Report
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!