caveattextoptionalThe name of a caveat of the model that must hold
Becomes the column caveat of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:42
A fact of relationship-based access: this subject has this relation to this object, perhaps under a caveat and until a time
Model identityRebac. Written in commons/data/models/identity-rebac/mod.ts:31. Identified by relationTupleId.
caveattextoptionalThe name of a caveat of the model that must hold
Becomes the column caveat of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:42
caveatContextstructuredoptionalThe values the caveat is given
Becomes the column caveat_context of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:43
createdAtinstantrequiredWhen the fact was recorded
Becomes the column created_at of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:45
expiresAtinstantoptionalWhen the fact stops holding
Becomes the column expires_at of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:44
objectIdtextrequiredThe object
Becomes the column object_id of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:37
objectTypetextrequiredThe kind of the object
Becomes the column object_type of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:36
relationtextrequiredThe relation
Becomes the column relation of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:38
relationTupleIdidentifierrequiredWhat identifies the fact, made by the application
Becomes the column relation_tuple_id of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:34
subjectIdtextrequiredThe subject
Becomes the column subject_id of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:40
subjectRelationtextoptionalThe relation of the subject that is meant, where a set is
Becomes the column subject_relation of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:41
subjectTypetextrequiredThe kind of the subject: a kind of principal, or a kind of object
Becomes the column subject_type of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:39
tupleKeytextrequiredA hash of the tenant, the object, the relation and the subject, unique, so that a fact is not recorded twice
Becomes the column tuple_key of relation_tuple.
Written at commons/data/models/identity-rebac/mod.ts:35
tenantoneThe tenant the fact is in To tenant. Written at commons/data/models/identity-rebac/mod.ts:31
Projects to the table relation_tuple with the primary key relation_tuple_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
caveat | text | true | attribute | relationTuple.caveat |
caveat_context | json | true | attribute | relationTuple.caveatContext |
created_at | timestamp | false | attribute | relationTuple.createdAt |
expires_at | timestamp | true | attribute | relationTuple.expiresAt |
object_id | text | false | attribute | relationTuple.objectId |
object_type | text | false | attribute | relationTuple.objectType |
relation | text | false | attribute | relationTuple.relation |
relation_tuple_id | text | false | attribute | relationTuple.relationTupleId |
subject_id | text | false | attribute | relationTuple.subjectId |
subject_relation | text | true | attribute | relationTuple.subjectRelation |
subject_type | text | false | attribute | relationTuple.subjectType |
tenant_id | text | false | reference | relationTuple.tenant |
tuple_key | text | false | attribute | relationTuple.tupleKey |
CREATE TABLE IF NOT EXISTS "relation_tuple" (
"relation_tuple_id" VARCHAR NOT NULL PRIMARY KEY,
"tuple_key" VARCHAR NOT NULL,
"object_type" VARCHAR NOT NULL,
"object_id" VARCHAR NOT NULL,
"relation" VARCHAR NOT NULL,
"subject_type" VARCHAR NOT NULL,
"subject_id" VARCHAR NOT NULL,
"subject_relation" VARCHAR,
"caveat" VARCHAR,
"caveat_context" JSON,
"expires_at" TIMESTAMPTZ,
"created_at" TIMESTAMPTZ NOT NULL,
"tenant_id" VARCHAR NOT NULL,
CONSTRAINT "relation_tuple_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
CONSTRAINT "relation_tuple_tuple_key_uq" UNIQUE ("tuple_key")
);CREATE TABLE IF NOT EXISTS "relation_tuple" (
"relation_tuple_id" TEXT NOT NULL PRIMARY KEY,
"tuple_key" TEXT NOT NULL,
"object_type" TEXT NOT NULL,
"object_id" TEXT NOT NULL,
"relation" TEXT NOT NULL,
"subject_type" TEXT NOT NULL,
"subject_id" TEXT NOT NULL,
"subject_relation" TEXT,
"caveat" TEXT,
"caveat_context" JSONB,
"expires_at" TIMESTAMPTZ,
"created_at" TIMESTAMPTZ NOT NULL,
"tenant_id" TEXT NOT NULL,
CONSTRAINT "relation_tuple_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
CONSTRAINT "relation_tuple_tuple_key_uq" UNIQUE ("tuple_key")
);CREATE TABLE IF NOT EXISTS "relation_tuple" (
"relation_tuple_id" TEXT NOT NULL PRIMARY KEY,
"tuple_key" TEXT NOT NULL,
"object_type" TEXT NOT NULL,
"object_id" TEXT NOT NULL,
"relation" TEXT NOT NULL,
"subject_type" TEXT NOT NULL,
"subject_id" TEXT NOT NULL,
"subject_relation" TEXT,
"caveat" TEXT,
"caveat_context" TEXT,
"expires_at" TEXT,
"created_at" TEXT NOT NULL,
"tenant_id" TEXT NOT NULL,
CONSTRAINT "relation_tuple_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
CONSTRAINT "relation_tuple_tuple_key_uq" UNIQUE ("tuple_key")
);Read and written from TypeScript with the types the model gives: import { relationTuple } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity-rebac.auto.ts: do not edit.
import { from } from "@intellectual-frontiers/data/sql/typed";
import { relationTuple } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(relationTuple).select((s) => ({ relationTupleId: s.relationTuple.relationTupleId, tupleKey: s.relationTuple.tupleKey })).run(runner);