fix: prevent duplicate indices when creating a new list
This commit is contained in:
@@ -24,7 +24,7 @@ export const create = async (
|
|||||||
orderBy: [desc(lists.index)],
|
orderBy: [desc(lists.index)],
|
||||||
});
|
});
|
||||||
|
|
||||||
const index = list?.index ? list.index + 1 : 0;
|
const index = list ? list.index + 1 : 0;
|
||||||
|
|
||||||
const [result] = await tx
|
const [result] = await tx
|
||||||
.insert(lists)
|
.insert(lists)
|
||||||
@@ -191,7 +191,7 @@ export const softDeleteAllByBoardId = async (
|
|||||||
deletedBy: string;
|
deletedBy: string;
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const [result] = await db
|
const result = await db
|
||||||
.update(lists)
|
.update(lists)
|
||||||
.set({ deletedAt: args.deletedAt, deletedBy: args.deletedBy })
|
.set({ deletedAt: args.deletedAt, deletedBy: args.deletedBy })
|
||||||
.where(and(eq(lists.boardId, args.boardId), isNull(lists.deletedAt)))
|
.where(and(eq(lists.boardId, args.boardId), isNull(lists.deletedAt)))
|
||||||
|
|||||||
Reference in New Issue
Block a user