fix: prevent duplicate indices when creating a new list

This commit is contained in:
Henry
2025-06-01 22:28:46 +01:00
parent 64c5488f0c
commit d602c1f960

View File

@@ -24,7 +24,7 @@ export const create = async (
orderBy: [desc(lists.index)],
});
const index = list?.index ? list.index + 1 : 0;
const index = list ? list.index + 1 : 0;
const [result] = await tx
.insert(lists)
@@ -191,7 +191,7 @@ export const softDeleteAllByBoardId = async (
deletedBy: string;
},
) => {
const [result] = await db
const result = await db
.update(lists)
.set({ deletedAt: args.deletedAt, deletedBy: args.deletedBy })
.where(and(eq(lists.boardId, args.boardId), isNull(lists.deletedAt)))