feat: add filter parameter
This commit is contained in:
parent
f06f7366b7
commit
4c28941bc2
1 changed files with 4 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ import {
|
|||
import { RequestWithUser } from "../interfaces/user";
|
||||
import prisma from "../db";
|
||||
import { notFoundError } from "../utils/error";
|
||||
import { queryOrNot } from "../utils/relation";
|
||||
|
||||
const MANAGE_ROLES = ["system", "head_of_admin", "admin"];
|
||||
|
||||
|
|
@ -52,9 +53,11 @@ export class InstitutionController extends Controller {
|
|||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() group?: string,
|
||||
) {
|
||||
const where = {
|
||||
name: { contains: query },
|
||||
group,
|
||||
OR: queryOrNot<Prisma.InstitutionWhereInput[]>(query, [{ name: { contains: query } }]),
|
||||
} satisfies Prisma.InstitutionWhereInput;
|
||||
|
||||
const [result, total] = await prisma.$transaction([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue