Understanding Permissions
Learn about row-level and column-level permissions to secure your app's data.
Why Permissions Matter
When building apps with database access, you need to control what data the AI can see and modify. Permissions let you:
- Protect sensitive information
- Limit AI actions to specific data
- Create secure multi-user apps
Permission Types
Row-Level Permissions
Row-level permissions control which records the AI can access. Think of rows as individual items in your data.
Example: In a customer database, you might want the AI to only see customers from a specific region:
{
"filter": {
"region": "North America"
}
}With this filter, the AI only sees customers where region equals "North America".
Column-Level Permissions
Column-level permissions control which fields the AI can access. Think of columns as the properties of each record.
Example: In a customer database, you might hide sensitive financial data:
Visible columns:
- name
- region
- last_contact
Hidden columns:
- credit_card
- annual_revenue
- internal_notes
Setting Up Permissions
Step 1: Enable Database
- Open your app settings
- Navigate to the Database tab
- Enable database access
Step 2: Create Collections
Collections are like tables in your database:
- Click Add Collection
- Name your collection (e.g., "customers")
- Define the schema (fields and types)
Step 3: Configure Row Filters
- Select a collection
- Click Row Permissions
- Define filter conditions
Filter operators:
equals: Exact matchcontains: Partial text matchgreaterThan: Numeric comparisonin: Match any value in a list
Step 4: Configure Column Access
- Select a collection
- Click Column Permissions
- Check/uncheck columns the AI can access
Common Patterns
User-Specific Data
Limit the AI to the current user's data:
{
"filter": {
"user_id": "{{current_user_id}}"
}
}Read-Only Access
Allow reading but prevent modifications:
{
"read": true,
"write": false,
"delete": false
}Hiding Sensitive Columns
Hide PII and financial data:
{
"hidden_columns": [
"ssn",
"credit_card",
"bank_account",
"salary"
]
}Testing Permissions
Always test your permissions:
- Create test data with various permission scenarios
- Ask the AI to retrieve filtered and unfiltered data
- Verify hidden columns aren't revealed
- Test write/delete operations if enabled
Best Practices
- Start restrictive: Give minimal access, then expand as needed
- Document your filters: Keep notes on why each filter exists
- Regular audits: Review permissions periodically
- Test edge cases: What happens with empty filters? Null values?