add insensitive search

This commit is contained in:
Kanjana 2025-04-09 14:05:05 +07:00
parent 743fde5493
commit afe54b1a4e

View file

@ -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,