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

224
Views
How to skip values realtime database firebase

I'm checking last 100000 measurements of humidity and make chart, but on chart I want to show every 100th measurement, how can I modify this code to do this:

firebase.database().ref("Humidity").ref.orderByChild("time").limitToLast(100000).on("child_added",snapshot => {
    var a = snapshot.val().wartosc;
    var b = (new Date(snapshot.val().time *1000)).toLocaleString("pl-PL");
    
addData(myChart, b, a);

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

This should do the trick:

firebase.database().ref("Humidity")  // ๐Ÿ‘ˆ Remove the extra ref here
.orderByChild("time")
.limitToLast(100000)
.on("value", snapshot => {           // ๐Ÿ‘ˆ use value instead of child_added
  let index = 0;
  snapshot.forEach((child) => {
    if (index++ % 1000 === 0) {      // ๐Ÿ‘ˆ check for every 1000th child
      var a = child.val().wartosc;
      var b = (new Date(child.val().time * 1000)).toLocaleString("pl-PL");
    }    
    addData(myChart, b, a);
  })
})

I've marked the main changes, but there may be some smaller changes needed too.

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!