MCPcopy
hub / github.com/apache/casbin / applyRemoveOperationToDatabase

Method applyRemoveOperationToDatabase

transaction_commit.go:176–189  ·  view source on GitHub ↗

applyRemoveOperationToDatabase applies a remove operation to the database.

(adapter persist.Adapter, op persist.PolicyOperation)

Source from the content-addressed store, hash-verified

174
175// applyRemoveOperationToDatabase applies a remove operation to the database.
176func (tx *Transaction) applyRemoveOperationToDatabase(adapter persist.Adapter, op persist.PolicyOperation) error {
177 if batchAdapter, ok := adapter.(persist.BatchAdapter); ok {
178 // Use batch operation if available.
179 return batchAdapter.RemovePolicies(op.Section, op.PolicyType, op.Rules)
180 } else {
181 // Fall back to individual operations.
182 for _, rule := range op.Rules {
183 if err := adapter.RemovePolicy(op.Section, op.PolicyType, rule); err != nil {
184 return err
185 }
186 }
187 }
188 return nil
189}
190
191// applyUpdateOperationToDatabase applies an update operation to the database.
192func (tx *Transaction) applyUpdateOperationToDatabase(adapter persist.Adapter, op persist.PolicyOperation) error {

Callers 1

Calls 2

RemovePoliciesMethod · 0.65
RemovePolicyMethod · 0.65

Tested by

no test coverage detected