-
Notifications
You must be signed in to change notification settings - Fork 13
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
add "page" at paginate parameter #802
Comments
We cannot really do that I think because "page" is not a notion known by the backend, it's a representation of each dapps.
or in JS
We can maybe have an example somewhere instead? |
yes, sample code will be helpful to show how to navigate from one page to another |
Let's do that! Maybe even a topic for a Juno Live stream. Thanks for the suggestion! |
Watched the live stream today, I guess you have to save all "startAfter" in an array for later "previous" function. As my understand, to implement pagination, the key has to be sequential, right? does it works for uuid? By using this pagination, we can't go to any specific page, like jump from page 2 to page 6, right? Do you have any thoughts for long term solution? |
Indeed it's probably what I will end up doing for next week. I have to review what I implemented in Juno Console. Live coding with time constraint is like going for a job interview, sometimes you take a wrong path and the interview does not go smoothly.
As long as the order is reproducible, pagination can be implemented. Wheter it's by key or timestamps, if the order can be reproduced, it's possible to iterate.
There is no notion of page in the smart contract. So if one developer needs this function, they should arhictecture their data to fits the needs, for example by using keys that can be predictable in that sense (which was not the case in the live stream).
Current implementation is the long term solution in my opinion. |
this is the code I use for paginate in motoko backend, not sure if it's helpful, FYI
|
Thanks for the share! It's not really applicable. Again, the current API should resolve any use case, it's about having the right structure of key. |
Let's finish the pagination we started this week in next Juno Live, this will address pagination with complex keys. If you need a pagination where "jumping on page 6" is required, then I think it can be addressed by key being a counter. However there is no out-of-the-box atomic counter yet so depends how precise it should be. |
it will be great to add a "page" option at paginate parameter of listDocs, which make page navigation easier.
e.g:
The text was updated successfully, but these errors were encountered: