MCPcopy Index your code
hub / github.com/apache/casbin / applyOperationsToDatabase

Method applyOperationsToDatabase

transaction_commit.go:135–157  ·  view source on GitHub ↗

applyOperationsToDatabase applies all buffered operations to the database.

()

Source from the content-addressed store, hash-verified

133
134// applyOperationsToDatabase applies all buffered operations to the database.
135func (tx *Transaction) applyOperationsToDatabase() error {
136 operations := tx.buffer.GetOperations()
137 txAdapter := tx.txContext.GetAdapter()
138
139 for _, op := range operations {
140 switch op.Type {
141 case persist.OperationAdd:
142 if err := tx.applyAddOperationToDatabase(txAdapter, op); err != nil {
143 return err
144 }
145 case persist.OperationRemove:
146 if err := tx.applyRemoveOperationToDatabase(txAdapter, op); err != nil {
147 return err
148 }
149 case persist.OperationUpdate:
150 if err := tx.applyUpdateOperationToDatabase(txAdapter, op); err != nil {
151 return err
152 }
153 }
154 }
155
156 return nil
157}
158
159// applyAddOperationToDatabase applies an add operation to the database.
160func (tx *Transaction) applyAddOperationToDatabase(adapter persist.Adapter, op persist.PolicyOperation) error {

Callers 1

CommitMethod · 0.95

Calls 5

GetOperationsMethod · 0.80
GetAdapterMethod · 0.65

Tested by

no test coverage detected