How to improve complex relationship reads #1908
-
Hey guys, we are using Authzed for 2 months now in our multitenant application. We basically have a tenant where the users can be inside a group and create resouces that can only be accessed by group members. We have a admin user that manage groups/users/resources inside a tenant and a master user that manages tenants. Our schema is something like that:
The admin user need to see all groups and its members so it can assing users to groups. Right now we are doing:
Its there a way to model the schema so i can get "All groups and its members from a specific tenant" at once? With examples:
I would like a way to list only the members from tenant ABC
Just using I keep thinking on how this could work in a RDBMS with JOINs, but i dont know if this is possible to do in performatic way with Authzed |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
One way is a LookupSubjects via the tenant. First, add the following to your
Then write relationships linking the tenant to each group (i.e. inverted from your current group->tenant). Then issue a LookupSubjects on |
Beta Was this translation helpful? Give feedback.
One way is a LookupSubjects via the tenant.
First, add the following to your
tenant
:Then write relationships linking the tenant to each group (i.e. inverted from your current group->tenant).
Then issue a LookupSubjects on
tenant:whoever#member
foruser
, and you should get back all the users for the tenant