Reputation: 117
is keyset pagination in front end only for next and previous ? because what I have learn about it, I could just use that N keep it for previous and. next
let say this query for page one,
SELECT * FROM nameTable ORDER BY ASC id LIMIT 10
and we save the last id on N
and then for next SELECT * FROM nameTable WHERE id > N ORDER BY ASC id LIMIT 10
and if for previous just use WHERE id < N
?
how about if in Client want to jump to the page 10 or back to 3 pages ??
can u all tell me how to do that and is that possible using keyset
?
Upvotes: 2
Views: 2271
Reputation: 577
Using keyset pagination you can not jump to a given page.
You can just go to first, last previous and next.
As explained by Laurenz, you can still move/skip a number "pages" from your current stand but I am not really sure what would be the use case for it.
The main objective of keyset pagination is to avoid the use of the offset/skip - limit for large sets of data, but if you want to jump to an exact page you must the offset/skip keywords.
Normally next and prev functionality using a good search gives good enough user experience :)
Upvotes: 5
Reputation: 248305
If you want to get to the previous page, remember the low bound for id
as well as the high bound.
To scroll 3 pages ahead, use LIMIT 30 OFFSET 20
instead of LIMIT 10
. To jump to page X, calculate the difference between X and the current page and multiply that difference with the number of rows per page.
It's all pretty straightforward.
Upvotes: 1