mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 17:26:07 +00:00
chore: refactor
This commit is contained in:
@@ -72,26 +72,5 @@ export const identityDALFactory = (db: TDbClient) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const countIdentitiesByFilter = async ({ searchTerm }: { searchTerm: string }) => {
|
return { ...identityOrm, getTrustedIpsByAuthMethod, getIdentitiesByFilter };
|
||||||
interface CountResult {
|
|
||||||
count: string;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const count = await db
|
|
||||||
.replicaNode()(TableName.Identity)
|
|
||||||
.where((qb) => {
|
|
||||||
if (searchTerm) {
|
|
||||||
void qb.whereILike(`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 };
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user