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

Function fire_after_delete

nodedb/src/control/trigger/fire_after.rs:125–163  ·  view source on GitHub ↗

Fire AFTER ROW triggers for a DELETE operation. `old_fields` is the deleted row. Available as OLD.field in the trigger body.

(
    state: &SharedState,
    identity: &AuthenticatedIdentity,
    tenant_id: TenantId,
    collection: &str,
    old_fields: &HashMap<String, nodedb_types::Value>,
    cascade_depth: u32,
    mode_

Source from the content-addressed store, hash-verified

123///
124/// `old_fields` is the deleted row. Available as OLD.field in the trigger body.
125pub async fn fire_after_delete(
126 state: &SharedState,
127 identity: &AuthenticatedIdentity,
128 tenant_id: TenantId,
129 collection: &str,
130 old_fields: &HashMap<String, nodedb_types::Value>,
131 cascade_depth: u32,
132 mode_filter: Option<TriggerExecutionMode>,
133) -> crate::Result<()> {
134 let triggers =
135 state
136 .trigger_registry
137 .get_matching(tenant_id.as_u64(), collection, DmlEvent::Delete);
138
139 let after_triggers: Vec<_> = triggers
140 .into_iter()
141 .filter(|t| t.timing == TriggerTiming::After)
142 .filter(|t| mode_filter.is_none() || Some(t.execution_mode) == mode_filter)
143 .collect();
144
145 if after_triggers.is_empty() {
146 return Ok(());
147 }
148
149 check_cascade_depth(cascade_depth, collection)?;
150
151 let bindings = RowBindings::after_delete(collection, old_fields.clone());
152
153 fire_triggers(
154 state,
155 identity,
156 tenant_id,
157 collection,
158 &after_triggers,
159 &bindings,
160 cascade_depth,
161 )
162 .await
163}
164
165/// Execute raw SQL in a trigger-like context (no row bindings).
166///

Callers 2

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