From afe54b1a4e7658cce4bca61bd2149df2963ace60 Mon Sep 17 00:00:00 2001 From: Kanjana Date: Wed, 9 Apr 2025 14:05:05 +0700 Subject: [PATCH] add insensitive search --- src/controllers/00-employment-office-controller.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/controllers/00-employment-office-controller.ts b/src/controllers/00-employment-office-controller.ts index e7efc24..95adc5a 100644 --- a/src/controllers/00-employment-office-controller.ts +++ b/src/controllers/00-employment-office-controller.ts @@ -2,6 +2,7 @@ import { Body, Controller, Get, Path, Post, Query, Route, Tags } from "tsoa"; import prisma from "../db"; import { queryOrNot } from "../utils/relation"; import { notFoundError } from "../utils/error"; +import { Prisma } from "@prisma/client"; @Route("/api/v1/employment-office") @Tags("Employment Office") @@ -40,11 +41,14 @@ export class EmploymentOfficeController extends Controller { ], [], ), - ...queryOrNot( + ...(queryOrNot( query, - [{ name: { contains: query } }, { nameEN: { contains: query } }], + [ + { name: { contains: query, mode: "insensitive" } }, + { nameEN: { contains: query, mode: "insensitive" } }, + ], [], - ), + ) satisfies Prisma.EmploymentOfficeWhereInput["OR"]), ...queryOrNot(!!body?.id, [{ id: { in: body?.id } }], []), ] : undefined,