MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / build_before_bindings

Function build_before_bindings

nodedb/src/control/trigger/batch/before.rs:135–150  ·  view source on GitHub ↗

Build RowBindings for a BEFORE trigger row.

(row: &TriggerBatchRow, collection: &str, operation: &str)

Source from the content-addressed store, hash-verified

133
134/// Build RowBindings for a BEFORE trigger row.
135fn 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}

Callers 1

execute_before_batchFunction · 0.85

Calls 5

new_fieldsMethod · 0.80
collectMethod · 0.80
old_fieldsMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected