show floors in descending order

This commit is contained in:
David Senoner 2025-05-19 16:40:11 +02:00
parent e3b9a83e73
commit cab2b67227
4 changed files with 48 additions and 40 deletions

View file

@ -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));
},
};