Skip to main content
This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the developer documentation.

RLS Examples

Practical Row-Level Security patterns for common application types. Important: Base44 RLS supports:
  • Logical operators: $or, $and, $nor for combining conditions
  • Field operators (for data.* fields): $in, $nin, $ne, $all
  • user_condition: Equality only (no operators)

Contents


Simple Patterns (JSON Schema)

These patterns work with the JSON schema RLS format.

Todo App - Owner-only access

Users see and manage only their own tasks.

Contact Form - Public create, admin-only read

Anyone can submit, only admins can view submissions.

User Profile - Self-management

Users can only access their own profile.

Department Data - Same department access

Users can only see records from their department.

Subscription - Admin-managed, user-readable via email field

Note: This pattern only allows users to read their own subscription. Admins need to use the Dashboard UI to configure additional read access for themselves.

Private Data - Owner-only

Public Read, Authenticated Write

Anyone can read, only logged-in users can create/edit their own records.

Using Operators

Logical Operators

Combine multiple conditions using $or, $and, or $nor: Owner OR Admin access:
Multiple roles with $or:

Field Operators for data.* Fields

Use $in, $nin, $ne, $all for comparing entity data fields: Access based on tags ($in):
Exclude specific statuses ($nin):
Not equal ($ne):
All tags must match ($all):

Combining Logical and Field Operators


Field-Level Security Examples

Control access to specific fields within an entity.

Sensitive Salary Field

Admin-Only Internal Fields


Complex Patterns (Dashboard UI or Backend)

Some patterns may still require the Dashboard UI or backend functions.

Bidirectional Relationships (e.g., Friendships, Matches)

Requirement: Either party in a relationship should have access. Now possible with $or:
Alternative solutions:
  1. Entity redesign: Store two records per relationship (one for each party)
  2. Backend function: Query with custom logic

Complex Business Logic

Requirement: Access depends on multiple entity fields with complex conditions. JSON Schema limitation: While operators help, very complex business logic may still be hard to express. Solution options:
  1. Backend function: Implement custom access logic
  2. Combine simpler rules: Break complex rules into simpler entity-level and field-level rules

Best Practices

Security Strategy

Use a combination of entity-level RLS and field-level security:

When to Use Each Approach

Common Role Patterns

Supported Operators Summary

Limitations Summary