addOrRemoveOperation() — supabase Function Reference
Architecture documentation for the addOrRemoveOperation() function in Privileges.utils.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD 74fabeda_b256_2a1b_02d5_6fee692b14eb["addOrRemoveOperation()"] 224303c5_4113_d7b1_8e35_e5de6e3707b8["usePrivilegesState()"] 224303c5_4113_d7b1_8e35_e5de6e3707b8 -->|calls| 74fabeda_b256_2a1b_02d5_6fee692b14eb style 74fabeda_b256_2a1b_02d5_6fee692b14eb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/Database/Privileges/Privileges.utils.ts lines 65–96
function addOrRemoveOperation(
operations: PrivilegeOperation[],
operation: PrivilegeOperation,
/** removes old operations and always adds the new one */
forceAdd = false
): PrivilegeOperation[] {
let state = [...operations]
const oppositeType = operation.type === 'grant' ? 'revoke' : 'grant'
const existing = state.find((op) => {
return (
op.object === operation.object &&
op.type === oppositeType &&
op.id === operation.id &&
op.grantee === operation.grantee &&
op.privilege_type === operation.privilege_type
)
})
if (existing !== undefined) {
state = state.filter((op) => op !== existing)
if (!forceAdd) {
return state
}
}
state.push(operation)
return state
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does addOrRemoveOperation() do?
addOrRemoveOperation() is a function in the supabase codebase.
What calls addOrRemoveOperation()?
addOrRemoveOperation() is called by 1 function(s): usePrivilegesState.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free