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

90
Views
Firebase filtering results

I have a question I read from realtime database 1000 last records but I need for example record number 100,200,300... can I do this ? I'm going to make chart and I want for example only show there every 10th measurement. My databse looks like that: enter image description here

 firebase.database().ref("Humidity").ref.orderByChild("time").limitToLast(1000).on("child_added",snapshot => {

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

0

It sounds like you're trying to built offset-based pagination, where you first show the most recent 100 messages, then the next 100, etc. That is not how pagination in Firebase works.

Pagination on Firebase follows a cursor model, and is based on knowing an anchor node. For example, if you've first shown the 100 most recent messages, you know the timestamp and key of the oldest message you've shown. You can then get the 100 messages before that with:

firebase.database().ref("Humidity")
  .orderByChild("time")
  .endAt(oldestTimeValue, oldestKey) // ๐Ÿ‘ˆ new
  .limitToLast(100)
  .on("child_added",snapshot => {

This:

  • orders the nodes by their time value.
  • finds the node whose time is oldestTimeValue and whose key (typically a push key like -M...) is oldestKey (just in case there are multiple nodes with the same time value).
  • then takes the 100 nodes before that one.
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!