From 549410e9e371cc2b463d51fc33e81229f267023f Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Wed, 30 Oct 2024 14:08:39 +0700 Subject: [PATCH] feat: add delete notification --- src/controllers/00-notification-controller.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/00-notification-controller.ts b/src/controllers/00-notification-controller.ts index 4fdfce8..a006858 100644 --- a/src/controllers/00-notification-controller.ts +++ b/src/controllers/00-notification-controller.ts @@ -17,6 +17,7 @@ import HttpStatus from "../interfaces/http-status"; import prisma from "../db"; import { Prisma } from "@prisma/client"; import { queryOrNot } from "../utils/relation"; +import { notFoundError } from "../utils/error"; type NotificationCreate = {}; type NotificationUpdate = {}; @@ -95,8 +96,8 @@ export class NotificationController extends Controller { @Delete("{notificationId}") @Security("keycloak") async deleteNotification(@Request() req: RequestWithUser, @Path() notificationId: string) { - // TODO: implement - - return {}; + const record = await prisma.notification.deleteMany({ where: { id: notificationId } }); + if (record.count === 0) throw notFoundError("Notification"); + return record; } }