'RavenDB paging via cursor

Paging in RavenDB is done via skip+take. This is default implementation I'm happy with most of the time. However for frequently changing data I want paging via a cursor. The cursor/after parameter specifies which was the last record displayed and where the list should continue on the next page. This should work for data which can be dynamically sorted, so the sorting parameter is not fixed.

github is doing it this way on the "stars" page for example: https://github.com/[username]?after=Y3Vyc29&tab=stars

Any ideas how to achieve this in RavenDB?



Solution 1:[1]

there is no cursor pagination in RavenDB. But you can use the 'last-modified to continuously iterate on frequently changing data.

from Orders as o
where o.'@metadata'.'@last-modified' > "2018-08-28:12:11" 
order by o.'@metadata'.'@last-modified'
select {
    A: o["@metadata"]["@last-modified"]
}. 

You can also use Subscription

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Igal Merhavia