Build RowBindings for a BEFORE trigger row.
(row: &TriggerBatchRow, collection: &str, operation: &str)
| 133 | |
| 134 | /// Build RowBindings for a BEFORE trigger row. |
| 135 | fn build_before_bindings(row: &TriggerBatchRow, collection: &str, operation: &str) -> RowBindings { |
| 136 | let new_row = row |
| 137 | .new_fields() |
| 138 | .map(|m| m.iter().map(|(k, v)| (k.clone(), v.clone())).collect()) |
| 139 | .unwrap_or_default(); |
| 140 | let old_row = row |
| 141 | .old_fields() |
| 142 | .map(|m| m.iter().map(|(k, v)| (k.clone(), v.clone())).collect()); |
| 143 | |
| 144 | match operation { |
| 145 | "INSERT" => RowBindings::before_insert(collection, new_row), |
| 146 | "UPDATE" => RowBindings::before_update(collection, old_row.unwrap_or_default(), new_row), |
| 147 | "DELETE" => RowBindings::before_delete(collection, old_row.unwrap_or_default()), |
| 148 | _ => RowBindings::before_insert(collection, new_row), |
| 149 | } |
| 150 | } |
no test coverage detected