Use filters and paginate #3567
-
Hello, My problem is the following: How to pass the query string from one query to another using pagination? Indeed, my page has filters that will alter the query string. My pagination resets to 1, it's perfect. But if I want to access page 2, using the
The question is : How to set up a filtration with a pagination allowing to change page while keeping the filters ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
https://github.com/adonisjs/lucid/blob/develop/src/Database/Paginator/SimplePaginator.ts#L144 This is the place where the mandatory addition of the ? takes place without taking into account an already existing qs. |
Beta Was this translation helpful? Give feedback.
-
So, after deep diving in the source code, I discover const { page = 1, ...qs } = request.qs()
const profiles = await Profile.query()
.filter(qs)
.preload('focusInterests')
.preload('role')
.paginate(page, this.PER_PAGE)
profiles.baseUrl(request.url()).queryString(qs)
return view.render('pages/mee/index', { profiles }) I will check if I can find this method in the documentation, otherwise, I make a PR! |
Beta Was this translation helpful? Give feedback.
So, after deep diving in the source code, I discover
queryString
which is exactly what I need!I will check if I can find this method in the documentation, otherwise, I make a PR!