<@U04UQ68083H> How to add a single relation to a n...
# ory-copilot
p
@chilly-king-10285 How to add a single relation to a namespace in Ory Permissions?
c
A message from kapa.ai
To add a single relation to a namespace in Ory Permissions, you need to define the relation within the corresponding class in the Ory Permission Language (OPL). Ory Permissions only has many-to-many relationships between objects and subjects. To reflect this in OPL, pluralize the relation name, for example,
viewers
instead of
viewer
. Here's an example of how to add a
viewers
relation to the
Document
namespace:
Copy code
typescript import { Namespace, Context } from "@ory/keto-namespace-types"  class User implements Namespace {}  class Document implements Namespace {   related: {     owners: User[]     editors: User[]     viewers: User[] // Add the viewers relation here     parents: Folder[]   } }  class Folder implements Namespace {   related: {     owners: User[]     editors: User[]     viewers: User[]     parents: Folder[]   } }
Source: [Create a permission model](https://www.ory.sh/docs/keto/modeling/create-permission-model)
p
@chilly-king-10285 Is it possible to create a one-to-many relationship between namespaces?
c
A message from kapa.ai
In Ory Permissions, only many-to-many relationships are supported between objects and subjects. However, you can model your relationships in a way that simulates a one-to-many relationship, but keep in mind that the underlying structure is still many-to-many. Source: [Create a permission model](https://www.ory.sh/docs/keto/modeling/create-permission-model)
p
Suppose it's my job to take care of the relationship being one-to-many.