Updating pagination method.
This commit is contained in:
parent
99536c2d0b
commit
90d646facb
2 changed files with 9 additions and 6 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 78b08caab8d83e03c5a4dde07e2e823dbb5d184f
|
Subproject commit 58338686c65024eb4140bb53965b618d9d647ec0
|
|
@ -177,7 +177,7 @@ export async function search(
|
||||||
const limit = params.limit
|
const limit = params.limit
|
||||||
if (paginate && params.limit) {
|
if (paginate && params.limit) {
|
||||||
request.paginate = {
|
request.paginate = {
|
||||||
limit: params.limit,
|
limit: params.limit + 1,
|
||||||
page: bookmark,
|
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
|
// get the rows
|
||||||
let finalRows = await outputProcessing<Row[]>(table, processed, {
|
let finalRows = await outputProcessing<Row[]>(table, processed, {
|
||||||
preserveLinks: true,
|
preserveLinks: true,
|
||||||
|
@ -217,10 +223,7 @@ export async function search(
|
||||||
limit: 1,
|
limit: 1,
|
||||||
page: bookmark * prevLimit + 1,
|
page: bookmark * prevLimit + 1,
|
||||||
}
|
}
|
||||||
// check if there is another row
|
const hasNextPage = !!nextRow
|
||||||
const nextRow = await runSqlQuery(request, allTables)
|
|
||||||
// check if there is a row found
|
|
||||||
const hasNextPage = Array.isArray(nextRow) && nextRow.length >= 1
|
|
||||||
response.hasNextPage = hasNextPage
|
response.hasNextPage = hasNextPage
|
||||||
if (hasNextPage) {
|
if (hasNextPage) {
|
||||||
response.bookmark = bookmark + 1
|
response.bookmark = bookmark + 1
|
||||||
|
|
Loading…
Reference in a new issue