1
0
Fork 0
mirror of synced 2024-05-14 09:23:42 +12:00
budibase/packages/server/src/api/controllers/public/mapping/tables.ts

27 lines
486 B
TypeScript

import { Table, TableOutput } from "../types/components"
function table(body: any): Table {
return {
_id: body._id,
name: body.name,
schema: body.schema,
primaryDisplay: body.primaryDisplay,
}
}
function mapTable(ctx: any): TableOutput {
return {
data: table(ctx.body),
}
}
function mapTables(ctx: any): { data: Table[] } {
const tables = ctx.body.map((body: any) => table(body))
return { data: tables }
}
export default {
mapTable,
mapTables,
}