Pagination in application which use firebase.com as database -
front end application use firebase.com database. application should work blog:
admin add / remove posts.
there "home" page show several articles per page "next" , "prev" buttons , page show single article.
also need deep linking. i.e. when user enter url http://mysite.com/page/2/ need application show last articles 10 20, when user enter url http://mysite.com/page/20/ application show last articles 200 210. usual pagination.
main question - possible achieve if use firebase.com.
i read docs @ firebase.com, read posts here. "offset()" , "count()" in future, use priority, in order know count of items , not load of them use additional counter.
based on suppose this:
add post action:
- get value of posts counter
- set priority new post data equals value of posts counter
- increase value of posts counter
delete post action
- get value of priority post data
- query posts data have value of priority more priority post data deleted , decrease value
- decrease value posts counter
get posts x y
- postsref.startat(null, x).endat(null, y).on(... , on)
thing not in way actions delete post. because index of posts 0 infinity , post less priority considered post created earlier if have 100000000 posts , if need delete 1st post need load data 99999999 next posts , update priority (index).
is there way?
thanks in advance, konstantin
as mentioned, offset() coming, makes job easier.
in meantime, rather using startat , endat in combination, use startat , limit in combination ensure n results. way, deleted items skipped. need check last id of each page before moving next find proper id start on.
Comments
Post a Comment