Answer the question
In order to leave comments, you need to log in
Pagination in firebase?
How to make pagination in firebase? Firebase does not have analogues of count and skip, which does not allow you to simply enter the page number and get the desired segment of records. There is a startAfter method that requires us to specify a specific entry there, after which we need to look for other entries.
The current mechanisms are suitable for infinite scrolling, when we know for sure this very previous entry. But what to do when you need to get records based on url? (e.g. "url.com/blog/3")
Load all posts and cut from array? Rave. And how to find out how many pages we have in total? Load all the records every time and count? Again nonsense.
Answer the question
In order to leave comments, you need to log in
So download 1 time all records and then "share".
Write yourself: get the total number of entries - divide by the number of entries that should be on the page = number of pages.
Here (2016!!!) it is written that there is limitToFirst(N).
Knowing the records-per-page - we get those that should be displayed.
I'll expand on the answer a bit. The Firebase Database REST API has a shallow=true query parameter that allows you to get data as a list of ids. This list looks like this:
{
-M9yIcQN7_DgcYVCBl6b: true,
-MAlDOMreZGUdg7quSjY: true,
-MAlDRLIsXnuF3zhgQyz: true,
-MABPqHqh7S0Gc4EKwLs: true,
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question