<@U04UQ68083H> class SubRoles implements Namespace...
# ory-copilot
l
@chilly-king-10285 class SubRoles implements Namespace{ related : { members: User[] locations: Location } } what is wrong with this?
c
A message from kapa.ai
The issue with your code is that the
locations
relation is not defined as an array. In Ory's permission model, relationships are always many-to-many, which means they should be defined as arrays. Here is the corrected code:
Copy code
typescript class SubRoles implements Namespace{   related : {     members: User[]     locations: Location[]   } }
For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-relationships-in-the-opl) on defining relationships in the Ory Permission Language.
l
@chilly-king-10285 But if I don't want to keep the many to many relationship?
c
A message from kapa.ai
In Ory's permission model, relationships are always many-to-many. This is a fundamental aspect of the model and it's not possible to change it to a one-to-many or one-to-one relationship. The many-to-many relationship model is used to reflect the complex nature of permissions and access control in real-world applications. If you have a use case where a
SubRole
is related to only one
Location
, you would still define
locations
as an array in the Ory model, but only add one
Location
to this array for each
SubRole
. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-relationships-in-the-opl) on defining relationships in the Ory Permission Language.