2022-02-24 11:13:16 +13:00
|
|
|
const { search, addRev } = require("./utils")
|
|
|
|
const controller = require("../table")
|
2022-02-19 04:47:15 +13:00
|
|
|
|
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-19 04:47:15 +13:00
|
|
|
|
2022-02-24 11:13:16 +13:00
|
|
|
exports.create = async ctx => {
|
|
|
|
await controller.save(ctx)
|
|
|
|
ctx.body = { table: ctx.body }
|
|
|
|
}
|
2022-02-19 04:47:15 +13:00
|
|
|
|
2022-02-24 11:13:16 +13:00
|
|
|
exports.read = async ctx => {
|
|
|
|
await controller.find(ctx)
|
|
|
|
ctx.body = { table: ctx.body }
|
|
|
|
}
|
2022-02-19 04:47:15 +13:00
|
|
|
|
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 }
|
|
|
|
}
|