RBAC, how to produce an actual flat list of user permissions

I want to pass on the names of the assigned permissions of the user to JS.
Generating the list of permissions by userId will include all parents/children.

For example, as per the RBAC example from the documentation

updateArticle
updateArticleOwn === children ===> updateArticle

calling getPermissionsByUserId will produce a list of

[
    'updateArticle',
    'updateArticleOwn',
]

However, in this case, I would like the list to only have the updateArticleOwn permission listed.

[
    'updateArticleOwn',
]

Does anyone have some sample code or suggestion on how to produce this type of permissions list?

Hi ptheofan, what is the relation between updateArticle and updateArticleOwn? And what permissions do this user have?

It seems the user have both permissions, in this case I think you should improve how you wan’t to filter this permissions, creating a custom query for this with more search parameters.