Refactor: merge find findPage - findAndPopulate findPageAndPopulate

This commit is contained in:
yassinedorbozgithub
2024-12-03 17:16:57 +01:00
parent acf3663bd5
commit cde4a36294
29 changed files with 82 additions and 163 deletions

View File

@@ -68,15 +68,9 @@ export class RoleController extends BaseController<
@Query(new SearchFilterPipe<Role>({ allowedFields: ['name'] }))
filters: TFilterQuery<Role>,
) {
if (pageQuery.limit) {
return this.canPopulate(populate)
? await this.roleService.findPageAndPopulate(filters, pageQuery)
: await this.roleService.findPage(filters, pageQuery);
}
return this.canPopulate(populate)
? await this.roleService.findAndPopulate(filters, pageQuery.sort)
: await this.roleService.find(filters, pageQuery.sort);
? await this.roleService.findAndPopulate(filters, pageQuery)
: await this.roleService.find(filters, pageQuery);
}
/**