Permalink
Browse files

feat(EntityRepository): add simple paging support

By setting both limit and page, the offset will be calculated and applied.
  • Loading branch information...
RWOverdijk committed Sep 23, 2018
1 parent bdbc8ae commit b588434c082187714ac95322beb7caf98e017771
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/EntityRepository.ts
@@ -139,6 +139,11 @@ export class EntityRepository<T> {
queryBuilder.where(criteria);
}
// Calculate offset if paging is being used.
if (options.page && options.limit) {
options.offset = (options.page - 1) * options.limit;
}
// Apply limit, offset etc.
this.applyOptions(queryBuilder, options);
@@ -231,6 +236,7 @@ export interface FindOptions {
orderBy?: any,
groupBy?: any,
alias?: string,
page?: number,
limit?: number,
offset?: number,
debug?: boolean,

0 comments on commit b588434

Please sign in to comment.