kaneo (minimalist kanban) fork to experiment adding a tangled integration
github.com/usekaneo/kaneo
1import { eq } from "drizzle-orm";
2import { HTTPException } from "hono/http-exception";
3import db from "../../database";
4import { columnTable } from "../../database/schema";
5
6async function updateColumn(
7 id: string,
8 data: {
9 name?: string;
10 icon?: string | null;
11 color?: string | null;
12 isFinal?: boolean;
13 },
14) {
15 const existing = await db.query.columnTable.findFirst({
16 where: eq(columnTable.id, id),
17 });
18
19 if (!existing) {
20 throw new HTTPException(404, { message: "Column not found" });
21 }
22
23 const [updated] = await db
24 .update(columnTable)
25 .set({
26 ...(data.name !== undefined && { name: data.name }),
27 ...(data.icon !== undefined && { icon: data.icon }),
28 ...(data.color !== undefined && { color: data.color }),
29 ...(data.isFinal !== undefined && { isFinal: data.isFinal }),
30 })
31 .where(eq(columnTable.id, id))
32 .returning();
33
34 if (!updated) {
35 throw new HTTPException(500, { message: "Failed to update column" });
36 }
37
38 return updated;
39}
40
41export default updateColumn;