Paging Backwards in Cosmos DB

你离开我真会死。 提交于 2021-01-27 20:25:45

问题


I'm trying to implement a simple paging system with c# and cosmos on my Vue front end, but i'm not really sure the best way to implement a the paging when the user wants to go back.

For going forward i'm using the continuation token, so cosmos know where i have got up to, but i'm not really sure on the best way to work this going backwards, or if the user goes from page 1 to 3, then back to page 2?

Will i have to cache the results as the user pages through the items, or is there another way to accomplish this?


回答1:


The way you can achieve that reliably is to keep all the tokens from these requests you've already been through in the client and then use the page number that the user is trying to get to an use the continuation token that corresponds to that page.




回答2:


Caching the results is fine. But I think you can cache the continuation tokens as well.

Just keep a map of page ids and continuation tokens. When you need to go back to a page, just issue a query with the cached continuation token. But, you have to pay for that query, unlike if you cache the results.

Note that, with this approach you can will go back, but not jump forward multiple pages.



来源:https://stackoverflow.com/questions/52357925/paging-backwards-in-cosmos-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!