Simplify the function signature of processInternalTables

This commit is contained in:
Sam Rose 2023-10-25 16:46:14 +01:00
parent e03b1be9d1
commit 4a00649f7f
No known key found for this signature in database
1 changed files with 6 additions and 4 deletions

View File

@ -19,8 +19,8 @@ import {
import datasources from "../datasources"
import sdk from "../../../sdk"
function processInternalTables(docs: AllDocsResponse<Table[]>): Table[] {
return docs.rows.map(tableDoc => processInternalTable(tableDoc.doc))
function processInternalTables(tables: Table[]): Table[] {
return tables.map(processInternalTable)
}
export function processInternalTable(table: Table): Table {
@ -40,7 +40,7 @@ export async function getAllInternalTables(db?: Database): Promise<Table[]> {
include_docs: true,
})
)
return processInternalTables(internalTables)
return processInternalTables(internalTables.rows.map(row => row.doc!))
}
async function getAllExternalTables(): Promise<Table[]> {
@ -110,7 +110,9 @@ export async function getTables(tableIds: string[]): Promise<Table[]> {
const internalTableDocs = await db.allDocs<Table[]>(
getMultiIDParams(internalTableIds)
)
tables = tables.concat(processInternalTables(internalTableDocs))
tables = tables.concat(
processInternalTables(internalTableDocs.rows.map(row => row.doc!))
)
}
return tables
}