Skip to content
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

Lack of pagination for getDocuments #2326

Open
owl352 opened this issue Nov 11, 2024 · 1 comment
Open

Lack of pagination for getDocuments #2326

owl352 opened this issue Nov 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@owl352
Copy link
Contributor

owl352 commented Nov 11, 2024

At this moment, we can get document from data contract using limit and startAt/startAfter
But startAt and startAfter only get Identifiers, which makes it impossible to paginate documents adequately
Also we dont have totalCount for documents

Expected Behavior

startAt and startAfter must get integers, because otherwise we need to create many requests for any page

Exmaple with limit 50 and page 10:

  • Create first and last request with limit 50 and startAfter equal 50*9

Current Behavior

As example we have limit 50, page 10, and the alghoritm to get it is:

  • Create first request with limit 100 and empty startAfter
  • Create second request with limit 100 and startAfter equal last identifier of document from previous request
  • Create second request with limit 100 and startAfter equal last identifier of document from previous request
  • Create second request with limit 100 and startAfter equal last identifier of document from previous request
  • Create second request with limit 50 and startAfter equal last identifier of document from previous request

Possible Solution

Replacing type for startAt and startAfter from identifier to integer on sever side and in clients and adding totalCount

@owl352 owl352 added the bug Something isn't working label Nov 11, 2024
@owl352 owl352 changed the title Lack of adequate pagination for getDocuments Lack of pagination for getDocuments Nov 11, 2024
@QuantumExplorer
Copy link
Member

totalCount sadly is not a capability of the current system, as it's impossible to prove the total amount without a node count. Such a feature would be possible by making a automatic count feature in grovedb, however it just hasn't been done yet.

The system is not designed to paginate integers either. This is because the underlying data might change, and you might miss values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants