I have a many to many relationship, users can manage many restaurants and restaurants can have many managers
by default users phone numbers are hidden but i want them to be available to other managers who manage the same restaurants as they do
I’ve added a field on the user Restaurants managing and on the restaurant managers, so my data could look like this:
“managers”: [U1, U2]
“manages”: [R1, R2]
U1 and U2 should be able to view each others phone numbers because they both manage the same restaurant but i can’t seem to write the privacy rule.
Am i storing my data correctly? how can i create the necessary privacy rule to allow them to view each others phone numbers?
One option is to have an “organization” type were U1 and U2 have the same organization so you can create an expression
current user's organization is this user's organization
doesn’t that lead to a similar problem? if i can have multiple organizations (same as multiple restaurants)
for some reason the dynamic expressions i can write with lists of things are much more limited than what i can do with a single thing
the point is that you make the organization a single field instead of a list.
Another approach is having a list of users so that you can create an expression like
current user's list of users contain this user, then you need to manually keep in sync this list when you add/remove managers from a restaurant