RLS DSL - v0.1.0
    Preparing search index...

    Variable sessionConst

    session: { get(key: string, type: SessionVariableType): ContextValue } = ...

    Session variable helper with type safety

    Access PostgreSQL session variables set via SET command or application context.

    Type Declaration

    • get: function
      • Get a session variable with type casting

        Maps to current_setting(key)::TYPE in PostgreSQL.

        Parameters

        • key: string

          Session variable key (e.g., 'app.current_tenant_id')

        • type: SessionVariableType

          Type to cast to ('integer', 'uuid', 'boolean', 'timestamp', or 'text')

        Returns ContextValue

        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'))
    );