Record ownership
RAIQL 0.10 extends role-based authorization with record ownership, so generated APIs can distinguish global access from access to records owned by the authenticated principal.
Declare the owner field
An owned entity needs a required field that stores the authenticated user identifier.
CREATE ENTITY Order (
id UUID PRIMARY,
total DECIMAL REQUIRED,
ownerId UUID REQUIRED
);
CREATE USER ENTITY User;
RELATE Order.ownerId TO User.id;
OWN Order BY ownerId;The ownership field must exist, be REQUIRED, and use the same scalar type as the generated user entity primary key. The explicit RELATE statement gives PostgreSQL referential integrity.
Scope permissions to OWN
ALLOW USER
CREATE OWN Order,
READ OWN Order,
UPDATE OWN Order,
DELETE OWN Order;OWN is a permission scope. A broad permission such as READ Order remains global, while READ OWN Order is restricted to rows whose ownership field matches the JWT sub claim.
Generated enforcement
For READ OWN, generated Prisma queries add an owner filter. For CREATE OWN, the server writes the authenticated principal into the owner field instead of trusting client input. UPDATE OWN and DELETE OWN first verify that the target record belongs to the principal and return 404 when it does not.
Admin + user pattern
ALLOW ADMIN CREATE Order, READ Order, UPDATE Order, DELETE Order;
ALLOW USER CREATE OWN Order, READ OWN Order, UPDATE OWN Order, DELETE OWN Order;This gives administrators a global view while ordinary users operate only on their own records. The generated authorization layer resolves the matching role/action rule and carries its scope into the database handler.
Current boundary
Executable ownership in RAIQL 0.10 targets DATABASE POSTGRESQL with JWT authentication. Nested ownership, organization/tenant scopes, delegated access and policy expressions are intentionally outside this release.