Always return when table exists
This commit is contained in:
parent
c565e35b53
commit
2d8361d6fd
|
@ -17,8 +17,15 @@ async function getTable(ctx: Ctx) {
|
||||||
export async function find(ctx: Ctx<void, RowActionsResponse>) {
|
export async function find(ctx: Ctx<void, RowActionsResponse>) {
|
||||||
const table = await getTable(ctx)
|
const table = await getTable(ctx)
|
||||||
|
|
||||||
const actions = await sdk.rowActions.get(table._id!)
|
if (!(await sdk.rowActions.docExists(table._id!))) {
|
||||||
|
ctx.body = {
|
||||||
|
tableId: table._id!,
|
||||||
|
actions: [],
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = await sdk.rowActions.get(table._id!)
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
...actions,
|
...actions,
|
||||||
|
|
|
@ -183,8 +183,14 @@ describe("/rowsActions", () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns 404 for tables without row actions", async () => {
|
it("returns empty for tables without row actions", async () => {
|
||||||
await config.api.rowAction.find(tableId, { status: 404 })
|
const response = await config.api.rowAction.find(tableId)
|
||||||
|
expect(response).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
tableId,
|
||||||
|
actions: [],
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -28,3 +28,10 @@ export async function get(tableId: string) {
|
||||||
const rowActionsId = generateRowActionsID(tableId)
|
const rowActionsId = generateRowActionsID(tableId)
|
||||||
return await db.get<TableRowActions>(rowActionsId)
|
return await db.get<TableRowActions>(rowActionsId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function docExists(tableId: string) {
|
||||||
|
const db = context.getAppDB()
|
||||||
|
const rowActionsId = generateRowActionsID(tableId)
|
||||||
|
const result = await db.exists(rowActionsId)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue