Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Hierarchy RLS

Hello ,

I have a data model that is connected this way : 
dm_user -> dm_ user_territory-> dm_territory -> ft_visit. 

I want to create a RLS rule using the email from the dm_user to filter the territory. 
The territory table has this hierarchy : 

RegionAreaterritory email
a  email a
ab email b
abcemail c
adeemail e

so A can see all the levels, B can see Area and Territory, C can only see territory. 

How can I set the RLS in the way that if I enter with Email A, I can see al the people ? and if I enter with Email B I can only see area and territory where B is the Area manager , and if I entere with email C I can only see territory with C?

Thank you in advance for the help. 

2 Replies