Updating pagination method.
This commit is contained in:
parent
99536c2d0b
commit
90d646facb
|
@ -1 +1 @@
|
|||
Subproject commit 78b08caab8d83e03c5a4dde07e2e823dbb5d184f
|
||||
Subproject commit 58338686c65024eb4140bb53965b618d9d647ec0
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue