mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
updated listing
This commit is contained in:
@ -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({
|
||||
|
Reference in New Issue
Block a user