Lots of updates and cleaning up.

This commit is contained in:
2026-02-14 12:08:23 -06:00
parent 7466bbdeac
commit 3ab443790c
17 changed files with 484 additions and 52 deletions
+31
View File
@@ -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;
},
};