From a78458510b99e919bb9b54f6d4c19c2429244f16 Mon Sep 17 00:00:00 2001 From: solufa Date: Sat, 20 Jul 2024 00:04:38 +0900 Subject: [PATCH] fix: replace task and image saving order --- server/domain/task/repository/taskCommand.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/domain/task/repository/taskCommand.ts b/server/domain/task/repository/taskCommand.ts index 6c00cda..61af45a 100644 --- a/server/domain/task/repository/taskCommand.ts +++ b/server/domain/task/repository/taskCommand.ts @@ -5,8 +5,6 @@ import type { TaskDeleteVal, TaskSaveVal } from '../model/taskEntity'; export const taskCommand = { save: async (tx: Prisma.TransactionClient, val: TaskSaveVal): Promise => { - if (val.s3Params !== undefined) await s3.put(val.s3Params); - await tx.task.upsert({ where: { id: val.task.id }, update: { label: val.task.label, done: val.task.done, imageKey: val.task.imageKey }, @@ -19,6 +17,8 @@ export const taskCommand = { authorId: val.task.author.id, }, }); + + if (val.s3Params !== undefined) await s3.put(val.s3Params); }, delete: async (tx: Prisma.TransactionClient, val: TaskDeleteVal): Promise => { assert(val.deletable);