show floors in descending order
This commit is contained in:
parent
e3b9a83e73
commit
cab2b67227
4 changed files with 48 additions and 40 deletions
|
@ -32,6 +32,13 @@ export const actions = {
|
|||
const floors = await db.select().from(table.floors);
|
||||
if (floors.length == 1) return fail(400, { message: "Cannot delete last floor!" });
|
||||
|
||||
const exists = await db
|
||||
.select({ floor: table.floors.floor })
|
||||
.from(table.floors)
|
||||
.where(eq(table.floors.floor, n));
|
||||
|
||||
if (exists.length == 0) return fail(400, { message: "Floor " + n + " does not exist!" });
|
||||
|
||||
await db.delete(table.floors).where(eq(table.floors.floor, n));
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue