1
0
Fork 0
mirror of synced 2024-06-29 11:31:06 +12:00
budibase/packages/server/src/api/controllers/public/tables.ts

40 lines
845 B
TypeScript
Raw Normal View History

2022-02-25 04:13:14 +13:00
import { search as stringSearch, addRev } from "./utils"
import { default as controller } from "../table"
2022-02-25 04:13:14 +13:00
export async function search(ctx: any) {
2022-02-24 11:13:16 +13:00
const { name } = ctx.request.body
await controller.fetch(ctx)
ctx.body = {
2022-02-25 04:13:14 +13:00
tables: stringSearch(ctx.body, name),
2022-02-24 11:13:16 +13:00
}
}
2022-02-25 04:13:14 +13:00
export async function create(ctx: any) {
2022-02-24 11:13:16 +13:00
await controller.save(ctx)
ctx.body = { table: ctx.body }
}
2022-02-25 04:13:14 +13:00
export async function read(ctx: any) {
2022-02-24 11:13:16 +13:00
await controller.find(ctx)
ctx.body = { table: ctx.body }
}
2022-02-25 04:13:14 +13:00
export async function update(ctx: any) {
2022-02-24 11:13:16 +13:00
ctx.request.body = await addRev(ctx.request.body, ctx.params.tableId)
await controller.save(ctx)
ctx.body = { table: ctx.body }
}
2022-02-25 04:13:14 +13:00
export async function destroy(ctx: any) {
2022-02-24 11:13:16 +13:00
await controller.destroy(ctx)
ctx.body = { table: ctx.table }
}
2022-02-25 04:13:14 +13:00
export default {
create,
read,
update,
destroy,
search,
}