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

32 lines
703 B
JavaScript
Raw Normal View History

2022-02-24 11:13:16 +13:00
const { search, addRev } = require("./utils")
const controller = require("../table")
2022-02-24 11:13:16 +13:00
exports.search = async ctx => {
const { name } = ctx.request.body
await controller.fetch(ctx)
ctx.body = {
tables: search(ctx.body, name),
}
}
2022-02-24 11:13:16 +13:00
exports.create = async ctx => {
await controller.save(ctx)
ctx.body = { table: ctx.body }
}
2022-02-24 11:13:16 +13:00
exports.read = async ctx => {
await controller.find(ctx)
ctx.body = { table: ctx.body }
}
2022-02-24 11:13:16 +13:00
exports.update = async ctx => {
ctx.request.body = await addRev(ctx.request.body, ctx.params.tableId)
await controller.save(ctx)
ctx.body = { table: ctx.body }
}
exports.delete = async ctx => {
await controller.destroy(ctx)
ctx.body = { table: ctx.table }
}