Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(limit): fix: use offset instead of skip #794

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/crud-typeorm/src/typeorm-crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ export class TypeOrmCrudService<T> extends CrudService<T> {
const take = this.getTake(parsed, options.query);
/* istanbul ignore else */
if (isFinite(take)) {
builder.take(take);
builder.limit(take);
}

// set skip
const skip = this.getSkip(parsed, take);
/* istanbul ignore else */
if (isFinite(skip)) {
builder.skip(skip);
builder.offset(skip);
}
}

Expand Down Expand Up @@ -358,8 +358,8 @@ export class TypeOrmCrudService<T> extends CrudService<T> {
): Promise<GetManyDefaultResponse<T> | T[]> {
if (this.decidePagination(query, options)) {
const [data, total] = await builder.getManyAndCount();
const limit = builder.expressionMap.take;
const offset = builder.expressionMap.skip;
const limit = builder.expressionMap.limit;
const offset = builder.expressionMap.offset;

return this.createPageInfo(data, total, limit || total, offset || 0);
}
Expand Down