From d602c1f960e87ba5bb7c373e0ca992c6b1c00ab4 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 1 Jun 2025 22:28:46 +0100 Subject: [PATCH] fix: prevent duplicate indices when creating a new list --- packages/db/src/repository/list.repo.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/db/src/repository/list.repo.ts b/packages/db/src/repository/list.repo.ts index 73ad5516..d57a567b 100644 --- a/packages/db/src/repository/list.repo.ts +++ b/packages/db/src/repository/list.repo.ts @@ -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)))