ConstGet a session variable with type casting
Maps to current_setting(key)::TYPE in PostgreSQL.
Session variable key (e.g., 'app.current_tenant_id')
Type to cast to ('integer', 'uuid', 'boolean', 'timestamp', or 'text')
A ContextValue representing the session variable
// Integer session variable
column('tenant_id').eq(session.get('app.tenant_id', 'integer'))
// UUID session variable
column('org_id').eq(session.get('app.org_id', 'uuid'))
// Boolean session variable
column('is_admin').eq(session.get('app.is_admin', 'boolean'))
// Text session variable (default)
column('role').eq(session.get('app.role', 'text'))
// Tenant isolation
policy('tenant_docs')
.on('documents')
.all()
.requireAll()
.when(
column('tenant_id').eq(session.get('app.current_tenant_id', 'integer'))
);
// Organization-based access
policy('org_projects')
.on('projects')
.read()
.when(
column('org_id').eq(session.get('app.org_id', 'uuid'))
);
Session variable helper with type safety
Access PostgreSQL session variables set via
SETcommand or application context.