platform icon indicating copy to clipboard operation
platform copied to clipboard

Lack of pagination for getDocuments

Open owl352 opened this issue 1 year ago • 1 comments

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 avatar Nov 11 '24 12:11 owl352

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.

QuantumExplorer avatar Nov 18 '24 15:11 QuantumExplorer