<@U04UQ68083H> I want to have field level control ...
# ory-copilot
g
@chilly-king-10285 I want to have field level control for the for the data base tables declared as an object in ory KETO. Can you give me a sample OPL for the same ?
c
A message from kapa.ai
Hmm, I don't know enough to give you a confident answer yet. The extracts provided do not contain specific information about field-level control for database tables declared as an object in Ory Keto using the Ory Permission Language (OPL). However, I can share that OPL is a developer-friendly configuration language defined as a subset of TypeScript. It's used to create permission rules and define relationships and permissions in Ory Keto. Here's a basic example of how you can define relationships and permissions in OPL:
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[]    parents: Folder[]    }       permits = {    view: (ctx: Context): boolean =>    this.related.viewers.includes(ctx.subject) ||    this.related.editors.includes(ctx.subject) ||    this.related.owners.includes(ctx.subject) ||    this.related.parents.traverse((parent) => parent.permits.view(ctx)),    }   }      class Folder implements Namespace {    related: {    owners: User[]    editors: User[]    viewers: User[]    parents: Folder[]    }   }
In this example,
User
,
Document
, and
Folder
are declared as namespaces (which can be considered as objects). Relationships are defined inside the corresponding class, and permissions are expressed as TypeScript functions that take a context containing the subject and answer permission checks based on the relationships the object has to the subject. For more detailed information and examples, you may want to refer to the [Ory Keto documentation](https://www.ory.sh/docs/keto).