
* feat(user-list): add pagination * feat: add actual total count in getUsers --------- Co-authored-by: Ali BARIN <ali.barin53@gmail.com>
26 lines
574 B
TypeScript
26 lines
574 B
TypeScript
import Context from '../../types/express/context';
|
|
import paginate from '../../helpers/pagination';
|
|
import User from '../../models/user';
|
|
|
|
type Params = {
|
|
limit: number;
|
|
offset: number;
|
|
};
|
|
|
|
const getUsers = async (_parent: unknown, params: Params, context: Context) => {
|
|
context.currentUser.can('read', 'User');
|
|
|
|
const usersQuery = User.query()
|
|
.leftJoinRelated({
|
|
role: true,
|
|
})
|
|
.withGraphFetched({
|
|
role: true,
|
|
})
|
|
.orderBy('full_name', 'asc');
|
|
|
|
return paginate(usersQuery, params.limit, params.offset);
|
|
};
|
|
|
|
export default getUsers;
|