0

I use firebase in React.js project. in firebase I have such collection. there nearly 400 IDs:

users:{
 '1JDJDHDHDSbBDBDB':20,
 '2JDJDHDHDSbBDBDB':8,
 '3JDJDHDHDSbBDBDB':23
    ...........
 '3JDJDHDHDSbBDBDB':79
 '3JDJDHDHDSbBDBDB':23
}

How to make a queries to load first 10 users, then the rest ?

I have tried with

limitToFirst=10

But cannot set range from 10 till rest..... thanks in advance.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Serhiy
  • 1,893
  • 9
  • 30
  • 48
  • 1
    Your `users` table structure should be like `users: { autoIncreatementedId : { id: 20}, autoIncreatementedId : { id: 8}} ...` Then you can perform `limitToFirst` query. The structure you have use `greaterThan` and `lessThan` query if you know the value. – TheTiger May 17 '18 at 07:23
  • There are quite a few questions about how to do [pagination with Firebase](https://stackoverflow.com/search?tab=votes&q=%5bfirebase-database%5d%5bjavascript%5d%20pagination). In your case, the second page would be a query with something like `ref.orderByKey().startAt(lastKeyOnPreviousPage)` as shown here: https://stackoverflow.com/a/47895422/209103 – Frank van Puffelen May 17 '18 at 14:04

0 Answers0