mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
fix: simplify logic
This commit is contained in:
parent
37ae2ec9ad
commit
91687f25ec
@ -279,18 +279,18 @@ 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,
|
||||
sort = ['createdAt', 'asc'],
|
||||
} = pageQuery || {};
|
||||
const query = this.model.find<T>(filter, projection);
|
||||
return query
|
||||
.skip(skip)
|
||||
.limit(limit)
|
||||
.sort([sort] as [string, SortOrder][]);
|
||||
}
|
||||
|
||||
const {
|
||||
skip = 0,
|
||||
limit = 0,
|
||||
sort = ['createdAt', 'asc'],
|
||||
} = pageQuery || {};
|
||||
const query = this.model.find<T>(filter, projection);
|
||||
return query
|
||||
.skip(skip)
|
||||
.limit(limit)
|
||||
.sort([sort] as [string, SortOrder][]);
|
||||
}
|
||||
|
||||
async find(
|
||||
@ -354,12 +354,12 @@ 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);
|
||||
}
|
||||
|
||||
const query = this.findQuery(filters, pageQuery, projection).populate(
|
||||
this.populate,
|
||||
);
|
||||
return await this.execute(query, this.clsPopulate);
|
||||
}
|
||||
|
||||
protected findAllQuery(
|
||||
|
Loading…
Reference in New Issue
Block a user