Companies are now listing properly
This commit is contained in:
@@ -17,4 +17,31 @@ export const companies = {
|
||||
|
||||
return new CompanyController(search);
|
||||
},
|
||||
|
||||
async count() {
|
||||
return await prisma.company.count();
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch Company Pages
|
||||
*
|
||||
* This is a method to be used to fetch pages of companies used for pagination.
|
||||
*
|
||||
* @param page - Page number
|
||||
* @param rpp - Records Per Page
|
||||
*/
|
||||
async fetchPages(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({
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user