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

440
Views
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 answers
Answer question

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 Report

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