looking for ideas/alternatives to providing a page/item count/navigation of items matching a GAE datastore query

前端 未结 4 1021
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 02:22

I like the datastore simplicity, scalability and ease of use; and the enhancements found in the new ndb library are fabulous.

As I understand datastore best practices, o

4条回答
  •  野的像风
    2021-02-06 03:03

    Maybe just aim for this style of paging:

    (first)(Prev)(Page1)(Page2)(Page3)....(Last)(next)

    That way the total number is not required - you only need your code to know that there is enough results for another 3+ pages. with page size of 10 items per page, you just need to know there are 30+ items.

    If you have 60 items, (enough for 6 pages) when youre already on page 4, your code would look forward and realise there are only another 20 records to go, so you could then show the last page number:

    (first)(Prev)(Page4)(Page5)(Page6)(next)(last)

    Basically for each fetch for the current page, just fetch enough records for another 3 pages of data, count them to see how many more pages you actully have, then dispaly your pager accordingly.

    Also, if you just fetch the keys, it will be more efficient than fetching extra items. hope that makes some sense!!?? :)

提交回复
热议问题