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

149
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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