refacto GET method with search param for offices
This commit is contained in:
parent
3ca6a0565d
commit
f3beea6c8c
@ -26,6 +26,19 @@ export default class OfficesController extends ApiController {
|
|||||||
if (req.query["q"]) {
|
if (req.query["q"]) {
|
||||||
query = JSON.parse(req.query["q"] as string);
|
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",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const officesEntities: Offices[] = await this.officesService.get(query);
|
const officesEntities: Offices[] = await this.officesService.get(query);
|
||||||
//Hydrate ressource with prisma entity
|
//Hydrate ressource with prisma entity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user