New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(kv): iter.cursor
returns non-empty string when limit
is defined
#20173
Comments
What happens if you do Returning the empty cursor requires looking ahead one entry past the limit, which is not done by default due to the overhead. |
That just increases the limit by 1, which doesn't fix the issue. If my previous setup had 10 posts per page, the setup now has 11. So when there are 11 posts, my setup will still point towards an empty second page. PTAL at my workaround in https://github.com/denoland/saaskit/pull/425/files#diff-fda30a2409d24fac1c4c1b607c96124b0329fe42338d678ec91f40c6a64efd57 |
@iuioiua When you use |
Ok, I see. Is this the recommended method for pagination? The behaviour still surprises me, and this is the first time I've seen this method being documented. I may not fully understand the performance implications. |
Yes, this is the only way to handle the corner case where |
Closing as this is expected behaviour. Thanks, @losfair! |
The following:
Produces (notice the empty last line):
However, when you set
const iter = kv.list({ prefix: ["posts"] }, { limit });
, the following output is produced (notice the non-empty last line):The consequence of using the last line as the
cursor
property forkv.list()
is that the next value is empty. In other words, the next page is blank. Instead, the last line should be blank. I hope my understanding is correct.Related denoland/saaskit#425
The text was updated successfully, but these errors were encountered: