feat: update repo funcs

This commit is contained in:
Henry
2025-12-01 21:06:41 +00:00
parent 48d3b43223
commit b664c566a1
3 changed files with 17 additions and 0 deletions

View File

@@ -164,6 +164,7 @@ export const getByPublicId = async (
description: true,
listId: true,
index: true,
dueDate: true,
},
with: {
labels: {
@@ -353,6 +354,7 @@ export const getBySlug = async (
description: true,
listId: true,
index: true,
dueDate: true,
},
with: {
labels: {

View File

@@ -23,6 +23,7 @@ export const create = async (
createdBy: string;
listId: number;
position: "start" | "end";
dueDate?: Date | null;
},
) => {
return db.transaction(async (tx) => {
@@ -71,6 +72,7 @@ export const create = async (
createdBy: cardInput.createdBy,
listId: cardInput.listId,
index: index,
dueDate: cardInput.dueDate ?? null,
})
.returning({ id: cards.id, listId: cards.listId });
@@ -163,6 +165,7 @@ export const update = async (
cardInput: {
title?: string;
description?: string;
dueDate?: Date | null;
},
args: {
cardPublicId: string;
@@ -173,6 +176,8 @@ export const update = async (
.set({
title: cardInput.title,
description: cardInput.description,
dueDate: cardInput.dueDate !== undefined ? cardInput.dueDate : undefined,
updatedAt: new Date(),
})
.where(and(eq(cards.publicId, args.cardPublicId), isNull(cards.deletedAt)))
.returning({
@@ -180,6 +185,7 @@ export const update = async (
publicId: cards.publicId,
title: cards.title,
description: cards.description,
dueDate: cards.dueDate,
});
return result;
@@ -214,6 +220,7 @@ export const getByPublicId = (db: dbClient, cardPublicId: string) => {
title: true,
description: true,
listId: true,
dueDate: true,
},
where: eq(cards.publicId, cardPublicId),
});
@@ -397,6 +404,7 @@ export const getWithListAndMembersByPublicId = async (
publicId: true,
title: true,
description: true,
dueDate: true,
},
with: {
labels: {
@@ -780,6 +788,7 @@ export const reorder = async (
publicId: true,
title: true,
description: true,
dueDate: true,
},
where: eq(cards.id, card.id),
});

View File

@@ -22,6 +22,8 @@ export const create = async (
commentId?: number;
fromComment?: string;
toComment?: string;
fromDueDate?: Date;
toDueDate?: Date;
sourceBoardId?: number;
},
) => {
@@ -45,6 +47,8 @@ export const create = async (
commentId: activityInput.commentId,
fromComment: activityInput.fromComment,
toComment: activityInput.toComment,
fromDueDate: activityInput.fromDueDate,
toDueDate: activityInput.toDueDate,
sourceBoardId: activityInput.sourceBoardId,
})
.returning({ id: cardActivities.id });
@@ -68,6 +72,8 @@ export const bulkCreate = async (
fromDescription?: string;
toDescription?: string;
createdBy: string;
fromDueDate?: Date;
toDueDate?: Date;
sourceBoardId?: number;
}[],
) => {