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

441
Vistas
How to get last value from firebase database to JavaScript?

I'm sending to firebase database information about humidity (value and time, showed in the link below and I have a question how can I get information about last measurement (value and time) in javascript because I want to show on the website information only about last measurement

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The way I'd do this is by attaching a timestamp to all of your documents (new Date().toISOString() in javascript) and then checking to find the most recent one using firebase .where() function in firestore: https://firebase.google.com/docs/firestore/query-data/queries.

This is assuming you're using firebase firestore. If you're using firebase realtime DB there should be a way to apply this concept of checking the most recent timestamps, just with different code.

about 4 years ago · Juan Pablo Isaza Denunciar

0

That'd be:

const ref = firebase.database().ref("Humidity");
const query = ref.orderByChild("time").limitToLast(1);
query.once("child_added").then((snapshot) => {
  console.log(snapshot.val().value);
});

I recommend reading:

  • the documentation on reading from Firebase
  • the documentation on ordering/filtering data.
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