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

140
Vistas
Getting a specific document from query Using Firebase Cloud functions

Im trying to get a user from a users collection with the most votes on a timed function. Ive been following the examples they have on the documentation, but still having trouble. Any thoughts?

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
admin.initializeApp();

exports.testData = functions.pubsub.schedule("30 14 * * *")
    .timeZone("America/New_York")
    .onRun((context) => {
      const test = admin.firestore().collection("users").
          orderBy("votes").limit(1);

      try {
        console.log("document data:", test.data());
      } catch (e) {
        console.log("Error getting document:", e);
      }
      return null;
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your code hasn't executed the query at all. It is just building a query object, then calling a method data() which doesn't exist on that object (likely causing your code to crash). I suggest reviewing the documentation to learn how to use get() to execute the query. It returns a promise that you must handle correctly.

return test.get()
    .then(snapshot => ...)
    .catch(error => ...)
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