mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +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)) {
|
if (Array.isArray(pageQuery)) {
|
||||||
const query = this.model.find<T>(filter, projection);
|
const query = this.model.find<T>(filter, projection);
|
||||||
return query.sort([pageQuery] as [string, SortOrder][]);
|
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(
|
async find(
|
||||||
@ -354,12 +354,12 @@ export abstract class BaseRepository<
|
|||||||
this.populate,
|
this.populate,
|
||||||
);
|
);
|
||||||
return await this.execute(query, this.clsPopulate);
|
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(
|
protected findAllQuery(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user