Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

443
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda