1
0
Fork 0
mirror of synced 2024-05-14 17:32:28 +12:00
budibase/packages/server/src/api/controllers/public/mapping/rows.ts

32 lines
584 B
TypeScript

import { Row, RowSearch, RowOutput } from "../types/components"
function row(body: any): Row {
delete body._rev
// have to input everything, since structure unknown
return {
...body,
_id: body._id,
tableId: body.tableId,
}
}
function mapRowSearch(ctx: any): RowSearch {
const rows = ctx.body.rows.map((body: any) => row(body))
return {
data: rows,
hasNextPage: ctx.body.hasNextPage,
bookmark: ctx.body.bookmark,
}
}
function mapRow(ctx: any): RowOutput {
return {
data: row(ctx.body),
}
}
export default {
mapRowSearch,
mapRow,
}