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

190
Visualizações
How to use firebase limits to paginate data

I'm used to php for backend, but I had to use firebase for this project cause of the realtime database...I am trying to paginate data loading. So far, I'm able to select the last 30 records using limitTolast(30). However, after this I need to select 30 older records after the last 30 I previously selected for when the user scrolls to the top...Please how do I achieve this

I already tried limtToLast(30).startAfter(30). thank you.

UPDATE

I found a solution, using endBefore(lastkey).limitToLast(1).However, its still not the best. The issue with this is, I would want to limitToLast(10) but if I do that, it runs the query 10 times with the same value as lastkey which causes repetition in my app. Please how can I fix this...What I would want is either get the last 10 records before lastkey once or allow me change the lastkey each time the query runs. I hope this makes sense

my code looks like this

this.db.child('messages/'+chatid).endBefore(this.state.messages[this.state.messages.length - 1].key).limitToLast(10).once('child_added', snapshot => this.parse(snapshot))
about 4 years ago · Juan Pablo Isaza
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