Hey team, apologies if this is obvious and I'm just missing something but I'm struggling to model ev...
s
Hey team, apologies if this is obvious and I'm just missing something but I'm struggling to model even the most basic of relationships. If I have a simple model of "Organisation" and "User" with a "User" being one of "administrators", "managers" or "users" on an Organisation. How would I model this so I can "List Organisations" that a subject has any of these relations with?
Copy code
import { Context, Namespace, SubjectSet } from "@ory/keto-namespace-types"

class User implements Namespace {}

class Organisation implements Namespace {
  related: {
    administrators: User[]
    managers: User[]
    users: (User | SubjectSet<Organisation, "managers"> | SubjectSet<Organisation, "administrators">)[]
  }

  permits = {
    view: (ctx: Context): boolean => this.related.users.includes(ctx.subject),
  }
}
With this model, attempting to use Subject Sets, I assume I would only be required to add an "administrators" relation between an admin User and an Organisation, along with the SubjectSet relations being set up once. This does not appear to work. When creating the relations, I run this js.
Copy code
await Promise.all([
            this.relations.createRelationship({
                createRelationshipBody: {
                    namespace: "Organisation",
                    object: organisationId,
                    relation: "administrators",
                    subject_id: subjectId,
                },
            }),
            this.relations.createRelationship({
                createRelationshipBody: {
                    namespace: "Organisation",
                    object: organisationId,
                    relation: "users",
                    subject_set: {
                        namespace: "Organisation",
                        object: organisationId,
                        relation: "administrators"
                    },
                },
            }),
            this.relations.createRelationship({
                createRelationshipBody: {
                    namespace: "Organisation",
                    object: organisationId,
                    relation: "users",
                    subject_set: {
                        namespace: "Organisation",
                        object: organisationId,
                        relation: "managers"
                    },
                },
            }),
        ])
And querying via this doesn't get me any results.
Copy code
this.relations.getRelationships({
                namespace: "Organisation",
                relation: "users",
                subjectId,
            }),
I'm hoping I'm just missing something really obvious here.