feat: adds pagination in identities table

This commit is contained in:
Piyush Gupta
2025-10-08 02:02:19 +05:30
parent 80754fe0b3
commit e7990c493b
8 changed files with 170 additions and 94 deletions
+22 -1
View File
@@ -60,5 +60,26 @@ export const identityDALFactory = (db: TDbClient) => {
}
};
return { ...identityOrm, getTrustedIpsByAuthMethod, getIdentitiesByFilter };
const countIdentitiesByFilter = async ({ searchTerm }: { searchTerm: string }) => {
interface CountResult {
count: string;
}
try {
const count = await db
.replicaNode()(TableName.Identity)
.where((qb) => {
if (searchTerm) {
void qb.whereILike(`${TableName.Identity}.name`, `%${searchTerm}%`);
}
})
.count("*")
.first();
return parseInt((count as unknown as CountResult).count || "0", 10);
} catch (error) {
throw new DatabaseError({ error, name: "Count identities by filter" });
}
};
return { ...identityOrm, getTrustedIpsByAuthMethod, getIdentitiesByFilter, countIdentitiesByFilter };
};