fix: simplify logic

This commit is contained in:
yassinedorbozgithub 2024-12-09 11:51:41 +01:00
parent 37ae2ec9ad
commit 91687f25ec

View File

@ -279,7 +279,8 @@ export abstract class BaseRepository<
if (Array.isArray(pageQuery)) {
const query = this.model.find<T>(filter, projection);
return query.sort([pageQuery] as [string, SortOrder][]);
} else {
}
const {
skip = 0,
limit = 0,
@ -291,7 +292,6 @@ export abstract class BaseRepository<
.limit(limit)
.sort([sort] as [string, SortOrder][]);
}
}
async find(
filter: TFilterQuery<T>,
@ -354,13 +354,13 @@ export abstract class BaseRepository<
this.populate,
);
return await this.execute(query, this.clsPopulate);
} else {
}
const query = this.findQuery(filters, pageQuery, projection).populate(
this.populate,
);
return await this.execute(query, this.clsPopulate);
}
}
protected findAllQuery(
sort?: QuerySortDto<T>,