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:

    1. get value of posts counter
    2. set priority new post data equals value of posts counter
    3. increase value of posts counter
  • delete post action

    1. get value of priority post data
    2. query posts data have value of priority more priority post data deleted , decrease value
    3. decrease value posts counter
  • get posts x y

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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -