I am looking for some help on what’s the best way to do this. I think I know but I am curious if I am way off base here or not. I want to have a condition that will check to make sure a team member is part of a certain company or set of possible companies when trying to do something against a client.
I added a condition down below and I am curious if this would be the best way to achieve this or not?
model
schema 1.1
type team_member
type company
relations
define member: [team_member]
type group
relations
define member: [team_member, group#member]
type clients
relations
define can_modify: owner
define can_view: viewer
define owner: [team_member with check_allowed_companies, group#member with check_allowed_companies]
define viewer: [team_member with check_allowed_companies, group#member with check_allowed_companies] or owner
condition check_allowed_companies(team_member_company: map<string>, allowed_companies: list<string>) {
team_member_company["company"] in allowed_companies
}