review changes

This commit is contained in:
Piyush Gupta
2025-10-09 18:55:49 +05:30
parent 4576fdfdbb
commit a090a1745c
8 changed files with 87 additions and 184 deletions
+13 -1
View File
@@ -50,11 +50,23 @@ export const identityDALFactory = (db: TDbClient) => {
});
}
const countQuery = query.clone();
if (sortBy) {
query = query.orderBy(sortBy);
}
return await query.limit(limit).offset(offset).select(selectAllTableCols(TableName.Identity));
const [identities, totalResult] = await Promise.all([
query.limit(limit).offset(offset).select(selectAllTableCols(TableName.Identity)),
countQuery.countDistinct(`${TableName.Identity}.id`, { as: "count" }).first()
]);
const total = Number(totalResult?.count || 0);
return {
identities,
total
};
} catch (error) {
throw new DatabaseError({ error, name: "Get identities by filter" });
}