Rowguard - RLS Policy DSL - v0.2.0
    Preparing search index...

    Interface TypedRowguard<DB>

    interface TypedRowguard<DB> {
        policy(name?: string): { on<T extends never>(table: T): PolicyBuilder };
        column<T extends never, C extends never>(table: T, col: C): ColumnBuilder;
        auth: {
            uid(): ContextValue;
            jwt(path?: string): ContextValue;
            role(): ContextValue;
        };
        session: { get(key: string, type: SessionVariableType): ContextValue };
        policies: TypedPolicies<DB>;
    }

    Type Parameters

    • DB
    Index

    Properties

    Methods

    Properties

    auth: {
        uid(): ContextValue;
        jwt(path?: string): ContextValue;
        role(): ContextValue;
    }
    session: { get(key: string, type: SessionVariableType): ContextValue }

    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'))
    policies: TypedPolicies<DB>

    Methods