Skip to content

Commit

Permalink
fix: add ordering by user ID in descending order (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSamuel committed Sep 11, 2024
1 parent fc13084 commit dee776c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/service/user-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export default class UserService {
}
}

builder.orderBy('user.id', 'DESC');

const users = await builder.limit(take).offset(skip).getRawMany();
const count = await builder.getCount();

Expand Down
4 changes: 2 additions & 2 deletions test/unit/controller/user-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ describe('UserController', (): void => {
const searchQuery = 'Firstname1 Last';
const res = await request(ctx.app)
.get('/users')
.query({ search: searchQuery })
.query({ search: searchQuery, take: 100, skip: 0 })
.set('Authorization', `Bearer ${ctx.adminToken}`);
expect(res.status).to.equal(200);

Expand All @@ -370,7 +370,7 @@ describe('UserController', (): void => {
expect(ids).to.includes(u.id);
});

expect(pagination.take).to.equal(defaultPagination());
expect(pagination.take).to.equal(100);
expect(pagination.skip).to.equal(0);

});
Expand Down

0 comments on commit dee776c

Please sign in to comment.