Current user context helper
Returns the current database user/role. Maps to current_user in PostgreSQL. This is different from auth.uid() - it returns the PostgreSQL role name, not the application user ID.
current_user
auth.uid()
A ContextValue representing the current database user
// Role-based access (database roles)policy('admin_access') .on('sensitive_data') .read() .when(column('allowed_role').eq(currentUser()));// Check if current database user matchespolicy('role_check') .on('audit_log') .read() .when(call('is_role_member', [currentUser(), 'auditor'])); Copy
// Role-based access (database roles)policy('admin_access') .on('sensitive_data') .read() .when(column('allowed_role').eq(currentUser()));// Check if current database user matchespolicy('role_check') .on('audit_log') .read() .when(call('is_role_member', [currentUser(), 'auditor']));
Current user context helper
Returns the current database user/role. Maps to
current_userin PostgreSQL. This is different fromauth.uid()- it returns the PostgreSQL role name, not the application user ID.