1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00

Updating pagination method.

This commit is contained in:
mike12345567 2024-05-23 14:37:41 +01:00
parent 99536c2d0b
commit 90d646facb
2 changed files with 9 additions and 6 deletions

@ -1 +1 @@
Subproject commit 78b08caab8d83e03c5a4dde07e2e823dbb5d184f
Subproject commit 58338686c65024eb4140bb53965b618d9d647ec0

View file

@ -177,7 +177,7 @@ export async function search(
const limit = params.limit
if (paginate && params.limit) {
request.paginate = {
limit: params.limit,
limit: params.limit + 1,
page: bookmark,
}
}
@ -195,6 +195,12 @@ export async function search(
}
)
// check for pagination final row
let nextRow: Row | undefined
if (paginate && params.limit && processed.length > params.limit) {
nextRow = processed.pop()
}
// get the rows
let finalRows = await outputProcessing<Row[]>(table, processed, {
preserveLinks: true,
@ -217,10 +223,7 @@ export async function search(
limit: 1,
page: bookmark * prevLimit + 1,
}
// check if there is another row
const nextRow = await runSqlQuery(request, allTables)
// check if there is a row found
const hasNextPage = Array.isArray(nextRow) && nextRow.length >= 1
const hasNextPage = !!nextRow
response.hasNextPage = hasNextPage
if (hasNextPage) {
response.bookmark = bookmark + 1