2 ms·
Usually a cursor holds some state about the last record shown to a user on a particular page. The next page should always start directly after the previous one,
by aarondf 5y ago
Usually a cursor holds some state about the last record shown to a user on a particular page. The next page should always start directly after the previous one, no matter how much time has elapsed.
Most frameworks have some kind of cursor implementation. Laravel's docs do a good job describing theirs: https://laravel.com/docs/8.x/pagination#cursor-pagination https://laravel.com/docs/8.x/pagination#cursor-pagination
- postalrat 5y agoSo what's the difference between that and using the id of the row like in the article?
- aarondf 5y agoWhen you use a cursor, the user has to pass a cursor back to the application to see the next page. So on the first page load, the server will send the records and a cursor that contains the info {'lastId': 32} and when the user requests page two, they'll have to send the cursor {'lastId': 32} so the server knows where to start. In practice, the cursors are usually encoded and appended to the URLs. You can never calculate what page 2 should be, you have to know what the last item on page 1 was, because that dictates where to start on page 2.