great-crayon-86888
11/13/2023, 8:55 AMchilly-king-10285
11/13/2023, 8:55 AMchilly-king-10285
11/13/2023, 8:56 AMCreateAppointment
class. Here's an example of how you might structure it: typescript import { Namespace, Context } from "@ory/keto-namespace-types" class InsuranceProfile implements Namespace {} class InsuranceProfileDetail implements Namespace {} class CreateAppointment implements Namespace { related: { insuranceProfiles: InsuranceProfile[] insuranceProfileDetails: InsuranceProfileDetail[] } permits = { createGroupAppointment: (ctx: Context): boolean => // Define your permission logic here. For example: this.related.insuranceProfiles.includes(ctx.subject) && this.related.insuranceProfileDetails.includes(ctx.subject) } }
In this example, the CreateAppointment
class has relationships with InsuranceProfile
and InsuranceProfileDetail
. The createGroupAppointment
permission is a function that takes the context and returns a boolean. You can define your permission logic within this function. Please note that this is a basic example and you might need to adjust it according to your specific needs and logic. For more information on how to create a permission model, you can refer to the [Create a permission model](https://www.ory.sh/docs/keto/modeling/create-permission-model) guide.great-crayon-86888
11/13/2023, 8:58 AMchilly-king-10285
11/13/2023, 8:58 AMchilly-king-10285
11/13/2023, 8:59 AMCreateAppointment
class within an Appointment
class and perform a permission check for the createGroupAppointment
permission. Here's an example of how you might structure it: typescript import { Namespace, Context } from "@ory/keto-namespace-types" class InsuranceProfile implements Namespace {} class InsuranceProfileDetail implements Namespace {} class CreateAppointment implements Namespace { related: { insuranceProfiles: InsuranceProfile[] insuranceProfileDetails: InsuranceProfileDetail[] } permits = { createGroupAppointment: (ctx: Context): boolean => // Define your permission logic here. For example: this.related.insuranceProfiles.includes(ctx.subject) && this.related.insuranceProfileDetails.includes(ctx.subject) } } class Appointment implements Namespace { related: { createAppointments: CreateAppointment[] } permits = { checkCreateAppointmentPermission: (ctx: Context): boolean => // Define your permission logic here. For example: this.related.createAppointments.some(appointment => appointment.permits.createGroupAppointment(ctx)) } }
In this example, the Appointment
class has a relationship with CreateAppointment
. The checkCreateAppointmentPermission
permission is a function that checks if any of the related CreateAppointment
objects have the createGroupAppointment
permission. Please note that this is a basic example and you might need to adjust it according to your specific needs and logic. For more information on how to create a permission model, you can refer to the [Create a permission model](https://www.ory.sh/docs/keto/modeling/create-permission-model) guide.