PR comments.
This commit is contained in:
parent
99e8ef58dd
commit
224d2a1953
|
@ -106,17 +106,12 @@ export async function search(
|
||||||
paginate: paginateObj as PaginationJson,
|
paginate: paginateObj as PaginationJson,
|
||||||
includeSqlRelationships: IncludeRelationship.INCLUDE,
|
includeSqlRelationships: IncludeRelationship.INCLUDE,
|
||||||
}
|
}
|
||||||
const queries: [
|
const [{ rows, rawResponseSize }, totalRows] = await Promise.all([
|
||||||
Promise<ExternalReadRequestReturnType>,
|
handleRequest(Operation.READ, tableId, parameters),
|
||||||
Promise<number> | undefined
|
countRows
|
||||||
] = [handleRequest(Operation.READ, tableId, parameters), undefined]
|
? handleRequest(Operation.COUNT, tableId, parameters)
|
||||||
if (countRows) {
|
: Promise.resolve(undefined),
|
||||||
queries[1] = handleRequest(Operation.COUNT, tableId, parameters)
|
])
|
||||||
}
|
|
||||||
const responses = await Promise.all(queries)
|
|
||||||
let rows = responses[0].rows
|
|
||||||
const rawResponseSize = responses[0].rawResponseSize
|
|
||||||
const totalRows = responses.length > 1 ? responses[1] : undefined
|
|
||||||
|
|
||||||
let processed = await outputProcessing<Row[]>(table, rows, {
|
let processed = await outputProcessing<Row[]>(table, rows, {
|
||||||
preserveLinks: true,
|
preserveLinks: true,
|
||||||
|
|
|
@ -332,20 +332,14 @@ export async function search(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const queries: Promise<Row[] | number>[] = []
|
const [rows, totalRows] = await Promise.all([
|
||||||
queries.push(runSqlQuery(request, allTables, relationships))
|
runSqlQuery(request, allTables, relationships),
|
||||||
if (options.countRows) {
|
options.countRows
|
||||||
// get the total count of rows
|
? runSqlQuery(request, allTables, relationships, {
|
||||||
queries.push(
|
|
||||||
runSqlQuery(request, allTables, relationships, {
|
|
||||||
countTotalRows: true,
|
countTotalRows: true,
|
||||||
})
|
})
|
||||||
)
|
: Promise.resolve(undefined),
|
||||||
}
|
])
|
||||||
const responses = await Promise.all(queries)
|
|
||||||
let rows = responses[0] as Row[]
|
|
||||||
const totalRows =
|
|
||||||
responses.length > 1 ? (responses[1] as number) : undefined
|
|
||||||
|
|
||||||
// process from the format of tableId.column to expected format also
|
// process from the format of tableId.column to expected format also
|
||||||
// make sure JSON columns corrected
|
// make sure JSON columns corrected
|
||||||
|
|
Loading…
Reference in New Issue