refacto GET method with search param for deed types

This commit is contained in:
OxSaitama 2023-07-13 15:32:47 +02:00
parent 3ca6a0565d
commit 8f40bd2464
2 changed files with 26 additions and 0 deletions

View File

@ -29,6 +29,19 @@ export default class DeedTypesController extends ApiController {
if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string);
}
if (req.query["search"] && typeof req.query["search"] === "string") {
const filter = req.query["search"];
query = {
where: {
name: {
contains: filter,
mode: "insensitive",
}
}
};
}
const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
if(!query.where) query.where = { office: officeWhereInput};

View File

@ -29,6 +29,19 @@ export default class DeedTypesController extends ApiController {
if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string);
}
if (req.query["search"] && typeof req.query["search"] === "string") {
const filter = req.query["search"];
query = {
where: {
name: {
contains: filter,
mode: "insensitive",
}
}
};
}
const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
if(!query.where) query.where = { office: officeWhereInput};