Closed dane-mckillop closed 1 year ago
Hi @dane-mckillop, thank you for using this lib.
The described behaviour is the intended one, the reason for this is that when the pagination returns a total
value this means it quarried the DB for it, meaning it made 2 queries.
I'm saving the return value of page 1 on the client, and then changing only the currentPage
value.
If you want to get the total
value for each page, you can pass the isLengthAware: true
, but pay attention that this will make 2 db queries for each page.
query.paginate({ perPage: 100, currentPage: 2, isLengthAware: true })
I'm closing this issue since it is not a bug, feel free to reopen it if you have any concerns
Passing the below line (have also hardcoded integers from 2-66 and same result), the pagination results will only partially generate such that total, lastPage, prevPage, nextPage are missing. Works as intended if pageNumber = 1 is provided. knex information is correct regardless.
Working from Windows 10 with knex-paginate 8.18.0 in my express application.
query.paginate({ perPage: 100, currentPage: req.query.page || 1 }) query.paginate({ perPage: 100, currentPage: 2 })