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

    Function policy

    • Create a new policy builder

      Parameters

      • Optionalname: string

        Optional name for the policy. If not provided, a name will be auto-generated based on the table, operation, and policy type.

      Returns PolicyBuilder

      A PolicyBuilder instance for fluent API chaining

      // Simple user ownership policy with explicit name
      const p = policy('user_documents')
      .on('documents')
      .read()
      .when(column('user_id').isOwner());

      // Auto-generated name -> "documents_select_policy"
      const p = policy()
      .on('documents')
      .read()
      .when(column('user_id').isOwner());

      // Auto-generated restrictive -> "documents_all_restrictive_policy"
      const p = policy()
      .on('documents')
      .all()
      .restrictive()
      .when(column('tenant_id').belongsToTenant());