updated listing

This commit is contained in:
hannathkadher
2025-01-12 13:40:48 +04:00
parent 4ee4097246
commit 65b7cf1f64
3 changed files with 50 additions and 9 deletions

View File

@ -98,14 +98,17 @@ export function TypeORMCustomModel(repository: Repository<any>) {
if (customQueryBuilder) {
const qb = customQueryBuilder.skip(skip).take(size);
if (order) {
Object.keys(order).forEach((key) => {
qb.addOrderBy(key, order[key]);
});
}
if (whereClause) {
qb.where(whereClause);
qb.andWhere(whereClause); // Use .andWhere instead of .where to avoid overwriting conditions
}
if (select) {
const selectColumns = Array.isArray(select)
? select
@ -114,6 +117,7 @@ export function TypeORMCustomModel(repository: Repository<any>) {
);
qb.select(selectColumns as string[]);
}
[data, count] = await qb.getManyAndCount();
} else {
[data, count] = await repository.findAndCount({