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

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

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