Promise.all for both counts (SQS and SQL).
This commit is contained in:
parent
0e5de7f16d
commit
bc80841554
|
@ -81,12 +81,12 @@ export async function search(
|
|||
paginate: paginateObj as PaginationJson,
|
||||
includeSqlRelationships: IncludeRelationship.INCLUDE,
|
||||
}
|
||||
const requests: Promise<Row[] | number>[] = []
|
||||
requests.push(handleRequest(Operation.READ, tableId, parameters))
|
||||
const queries: Promise<Row[] | number>[] = []
|
||||
queries.push(handleRequest(Operation.READ, tableId, parameters))
|
||||
if (countRows) {
|
||||
requests.push(handleRequest(Operation.COUNT, tableId, parameters))
|
||||
queries.push(handleRequest(Operation.COUNT, tableId, parameters))
|
||||
}
|
||||
const responses = await Promise.all(requests)
|
||||
const responses = await Promise.all(queries)
|
||||
let rows = responses[0] as Row[]
|
||||
const totalRows = responses[1] ? (responses[1] as number) : undefined
|
||||
|
||||
|
|
|
@ -213,7 +213,19 @@ export async function search(
|
|||
}
|
||||
|
||||
try {
|
||||
const rows = await runSqlQuery(request, allTables)
|
||||
const queries: Promise<Row[] | number>[] = []
|
||||
queries.push(runSqlQuery(request, allTables))
|
||||
if (options.countRows) {
|
||||
// get the total count of rows
|
||||
queries.push(
|
||||
runSqlQuery(request, allTables, {
|
||||
countTotalRows: true,
|
||||
})
|
||||
)
|
||||
}
|
||||
const responses = await Promise.all(queries)
|
||||
let rows = responses[0] as Row[]
|
||||
const totalRows = responses[1] ? (responses[1] as number) : undefined
|
||||
|
||||
// process from the format of tableId.column to expected format also
|
||||
// make sure JSON columns corrected
|
||||
|
@ -231,14 +243,6 @@ export async function search(
|
|||
nextRow = processed.pop()
|
||||
}
|
||||
|
||||
let totalRows: number | undefined
|
||||
if (options.countRows) {
|
||||
// get the total count of rows
|
||||
totalRows = await runSqlQuery(request, allTables, {
|
||||
countTotalRows: true,
|
||||
})
|
||||
}
|
||||
|
||||
// get the rows
|
||||
let finalRows = await outputProcessing<Row[]>(table, processed, {
|
||||
preserveLinks: true,
|
||||
|
|
Loading…
Reference in New Issue