You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: Pagination is a pain. It is so much of an ugly pain the pagination docs, don't ever try iterating over paginated results, instead showing how to disable pagination!
Solution: a next iterator hook.
Without Hook:
asyncfunctionmain(){allMessages=[];letpage=1;letresult;do{result=awaitapp.service('messages').find({query: {$limit: 10,// Change `10` to the maximum number of messages you want to retrieve per page$skip: (page-1)*10,// Change `10` to the maximum number of messages you want to retrieve per page},});allMessages.push(...result.data);page++;}while(result.total>allMessages.length);allMessages.forEach(console.log)}
Steps to reproduce
Problem: Pagination is a pain. It is so much of an ugly pain the pagination docs, don't ever try iterating over paginated results, instead showing how to disable pagination!
Solution: a next iterator hook.
Without Hook:
With the Hook:
Note how there is zero math involved in userland. Both userland code and the hook itself is somewhat stateless, every variable is a constant.
Proposed implementation:
https://stackblitz.com/edit/lowdb-qs-browser-nbkcvk?file=index.html%3AL89,app.ts
The text was updated successfully, but these errors were encountered: