Feature(s) impacted
I would like to be able to use cursor based pagination on a smart collection and both be able to page back and forth in the results.
Observed behavior
With a collection like
collection('myCollection', {
isSearchable: true,
paginationType: 'cursor',
fields: [
{
field: 'id',
type: 'String'
},
...
]
)
In the route handler I can extract req.query.search_after
when paging forwards to display the next page of results, but the button to go to the previous page stays disabled at all times and the page number is always 1.
This means that:
- I cannot page back, only refreshing the page lets me start from the beginning
- I can page past the last result and end up with a “No results” view.
Expected behavior
I am wondering if cursor based pagination is fully supported. Possibly through additional meta attributes returned, which indicate if there are more items to fetch? Not sure if this is already possible as it is not documented at all.
Context
- Project name: Monta
- Team name: …
- Environment name: Development | haukelange
- Agent (forest package) name & version: “forest-express-sequelize”: “^9.3.11”
- Database type: mysql
Hello @Hauke_Lange and welcome to the community !
After an investigation we have reproduced the issue, a task has been created to fix the bug.
Thanks for the report, we’ll keep you updated once the release has been made.
Best regards,
Hello @Hauke_Lange,
The fix on the cursor based pagination has been released, you should be able to navigate between pages
Regards,
Nicolas
Hi again
Thanks for looking into this and providing the fix. I can see that the ending_before
timestamp is now also present when paging, but it is still not usable for me, unfortunately.
This is happening for me:
- request first page for the first time:
starting_after and ending_before are not set
- go to page 2:
starting_after is set to the last element of the first page
- go back to page 1:
ending_before is set to the first element of the second page
starting_after is set to the last element of the first page
- go back to page 2:
ending_before is set to the first element of the second page
starting_after is set to the last element of the first page
Also if I change the filters, the cursors and page number aren’t cleared, which means I most likely end up with an invalid page number on the new result set.
There seems to be some statefulness going on. I would only ever expect one of the two to be present. In the backend, I cannot determine which direction we are paging if both are set. Is there some aspect I am missing? Some metadata I need to return with the results?
Hello @Hauke_Lange
You’re right, I will fix this and tell you when it’s live
Hi again @Hauke_Lange
The new fix has been released. Now you should only receive one of starting_after
and ending_before
Hi Nicolas
I can see it is working now. Thank you so much for the quick turnaround!
Best,
Hauke
1 Like