i’m currently searching for a solution to save the mongodb cursor (after a find()) to access it between two http requests. My environment is JAVA Spring MVC and mongodb (Spring Data) so i have all of its powerfull functionality. Unfortunately i didn’t find any documentation/tutorial which solves my problem:
A client requests the first 20 results in his first request and the following 20 in his second request. Instead of querying mongo again i want to access the previously generated cursor because documents changed during time and i want to have the initial order of them. Is there any way how to do it?
Help is very welcome!
You could also try to iterate through the
Cursorand add everything to aSortedMap. Then you can query theSortedMapas many times as you want. You can have theSortedMapsort it by natural order or you can use aComparatorto have it sorted any way you want.