Lack of pagination for getDocuments
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
limit50 andstartAfterequal 50*9
Current Behavior
As example we have limit 50, page 10, and the alghoritm to get it is:
- Create first request with
limit100 and emptystartAfter - Create second request with
limit100 andstartAfterequal last identifier of document from previous request - Create second request with
limit100 andstartAfterequal last identifier of document from previous request - Create second request with
limit100 andstartAfterequal last identifier of document from previous request - Create second request with
limit50 andstartAfterequal 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
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.