This commit is contained in:
Adria Navarro 2023-09-27 18:46:13 +02:00
parent 0cec026932
commit fad4f12e26
2 changed files with 12 additions and 3 deletions

View File

@ -133,7 +133,11 @@ export async function find(ctx: UserCtx): Promise<Row> {
} }
const table = await sdk.tables.getTable(tableId) const table = await sdk.tables.getTable(tableId)
return await outputProcessing(table, row) // Preserving links, as the outputProcessing does not support external rows yet and we don't need it in this use case
return await outputProcessing(table, row, {
squash: false,
preserveLinks: true,
})
} }
export async function destroy(ctx: UserCtx) { export async function destroy(ctx: UserCtx) {

View File

@ -200,7 +200,10 @@ export async function inputProcessing(
export async function outputProcessing<T extends Row[] | Row>( export async function outputProcessing<T extends Row[] | Row>(
table: Table, table: Table,
rows: T, rows: T,
opts = { squash: true } opts: { squash?: boolean; preserveLinks?: boolean } = {
squash: true,
preserveLinks: false,
}
): Promise<T> { ): Promise<T> {
let safeRows: Row[] let safeRows: Row[]
let wasArray = true let wasArray = true
@ -211,7 +214,9 @@ export async function outputProcessing<T extends Row[] | Row>(
safeRows = rows safeRows = rows
} }
// attach any linked row information // attach any linked row information
let enriched = await linkRows.attachFullLinkedDocs(table, safeRows) let enriched = !opts.preserveLinks
? await linkRows.attachFullLinkedDocs(table, safeRows)
: safeRows
// process formulas // process formulas
enriched = processFormulas(table, enriched, { dynamic: true }) as Row[] enriched = processFormulas(table, enriched, { dynamic: true }) as Row[]