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

Function fire_after_update

nodedb/src/control/trigger/fire_after.rs:81–120  ·  view source on GitHub ↗
(
    state: &SharedState,
    identity: &AuthenticatedIdentity,
    tenant_id: TenantId,
    collection: &str,
    old_fields: &HashMap<String, nodedb_types::Value>,
    new_fields: &HashMap<String, 

Source from the content-addressed store, hash-verified

79/// Both are available as OLD.field and NEW.field in the trigger body.
80#[allow(clippy::too_many_arguments)]
81pub async fn fire_after_update(
82 state: &SharedState,
83 identity: &AuthenticatedIdentity,
84 tenant_id: TenantId,
85 collection: &str,
86 old_fields: &HashMap<String, nodedb_types::Value>,
87 new_fields: &HashMap<String, nodedb_types::Value>,
88 cascade_depth: u32,
89 mode_filter: Option<TriggerExecutionMode>,
90) -> crate::Result<()> {
91 let triggers =
92 state
93 .trigger_registry
94 .get_matching(tenant_id.as_u64(), collection, DmlEvent::Update);
95
96 let after_triggers: Vec<_> = triggers
97 .into_iter()
98 .filter(|t| t.timing == TriggerTiming::After)
99 .filter(|t| mode_filter.is_none() || Some(t.execution_mode) == mode_filter)
100 .collect();
101
102 if after_triggers.is_empty() {
103 return Ok(());
104 }
105
106 check_cascade_depth(cascade_depth, collection)?;
107
108 let bindings = RowBindings::after_update(collection, old_fields.clone(), new_fields.clone());
109
110 fire_triggers(
111 state,
112 identity,
113 tenant_id,
114 collection,
115 &after_triggers,
116 &bindings,
117 cascade_depth,
118 )
119 .await
120}
121
122/// Fire AFTER ROW triggers for a DELETE operation.
123///

Callers 3

fire_for_operationFunction · 0.85

Calls 7

check_cascade_depthFunction · 0.85
fire_triggersFunction · 0.85
get_matchingMethod · 0.80
collectMethod · 0.80
as_u64Method · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected