We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi ! I need to get all the users with a given permission
I've tried this
const results = await getRepository(Permission).find({ where: {codeName:"permission"}, relations:["groups"] })
Unfortunately the permission entity doesn't include a Group[] column
export declare class Permission { id: number; name: string; codeName: string; }
so i got this error :
Relation "groups" was not found, please check if it is correct and really exist in your entity.
Would it be possible to add the Many-to-Many relation for both users and groups ?
I fear of a circular reference and i am not sure how to do that, but if it is possible, i could probably do it and make a pull request.
Best regards !
The text was updated successfully, but these errors were encountered:
Hi @esunea
In which case do you need to get all the users with a given permission?
Here is a way to fetch them:
const codeName = 'perm2'; const users = await getRepository(User) .createQueryBuilder('user') .innerJoin('user.userPermissions', 'userPermission') .innerJoin('user.groups', 'group') .innerJoin('group.permissions', 'groupPermission') .where('userPermission.codeName = :codeName', { codeName }) .orWhere('groupPermission.codeName = :codeName', { codeName }) .getMany();
Sorry, something went wrong.
I'm sorry, the above code does not work on some particular cases. Version 1.8 will include a proper and tested static method for this: #682
No branches or pull requests
Hi !
I need to get all the users with a given permission
I've tried this
Unfortunately the permission entity doesn't include a Group[] column
so i got this error :
Relation "groups" was not found, please check if it is correct and really exist in your entity.
Would it be possible to add the Many-to-Many relation for both users and groups ?
I fear of a circular reference and i am not sure how to do that, but if it is possible, i could probably do it and make a pull request.
Best regards !
The text was updated successfully, but these errors were encountered: