From 0bca85d4603e32a469239b70d8d8943d4a87ed61 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:41:07 +0700 Subject: [PATCH] feat: return only one record --- src/controllers/employee-other-info-controller.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/controllers/employee-other-info-controller.ts b/src/controllers/employee-other-info-controller.ts index 58e0ff5..3cb6284 100644 --- a/src/controllers/employee-other-info-controller.ts +++ b/src/controllers/employee-other-info-controller.ts @@ -38,23 +38,12 @@ type EmployeeOtherInfoPayload = { export class EmployeeOtherInfo extends Controller { @Get() async list(@Path() employeeId: string) { - return prisma.employeeOtherInfo.findMany({ + return prisma.employeeOtherInfo.findFirst({ orderBy: { createdAt: "asc" }, where: { employeeId }, }); } - @Get("{otherInfoId}") - async getById(@Path() employeeId: string, @Path() otherInfoId: string) { - const record = await prisma.employeeOtherInfo.findFirst({ - where: { id: otherInfoId, employeeId }, - }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee info cannot be found.", "data_not_found"); - } - return record; - } - @Post() async create( @Request() req: RequestWithUser,