Lots of updates and cleaning up.
This commit is contained in:
@@ -40,4 +40,35 @@ export const companies = {
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Search Companies
|
||||
*
|
||||
* Search companies by identifier, name, or id with pagination support.
|
||||
*
|
||||
* @param query - Search query string
|
||||
* @param page - Page number
|
||||
* @param rpp - Records Per Page
|
||||
*/
|
||||
async search(query: string, page: number, rpp: number) {
|
||||
page = page.valueOf();
|
||||
rpp = rpp.valueOf();
|
||||
|
||||
const skip = (page > 1 ? page : 0) * rpp;
|
||||
const take = rpp ?? 30;
|
||||
|
||||
const data = prisma.company.findMany({
|
||||
where: {
|
||||
OR: [
|
||||
{ cw_Identifier: { contains: query, mode: "insensitive" } },
|
||||
{ name: { contains: query, mode: "insensitive" } },
|
||||
{ id: { contains: query, mode: "insensitive" } },
|
||||
],
|
||||
},
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user