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

Function fire_instead_of_delete

nodedb/src/control/trigger/fire_instead.rs:122–160  ·  view source on GitHub ↗

Check for and fire INSTEAD OF triggers for a DELETE operation.

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

Source from the content-addressed store, hash-verified

120
121/// Check for and fire INSTEAD OF triggers for a DELETE operation.
122pub async fn fire_instead_of_delete(
123 state: &SharedState,
124 identity: &AuthenticatedIdentity,
125 tenant_id: TenantId,
126 collection: &str,
127 old_fields: &HashMap<String, nodedb_types::Value>,
128 cascade_depth: u32,
129) -> crate::Result<InsteadOfResult> {
130 let triggers =
131 state
132 .trigger_registry
133 .get_matching(tenant_id.as_u64(), collection, DmlEvent::Delete);
134
135 let instead_triggers: Vec<_> = triggers
136 .into_iter()
137 .filter(|t| t.timing == TriggerTiming::InsteadOf)
138 .collect();
139
140 if instead_triggers.is_empty() {
141 return Ok(InsteadOfResult::NoTrigger);
142 }
143
144 check_cascade_depth(cascade_depth, collection)?;
145
146 let bindings = RowBindings::before_delete(collection, old_fields.clone());
147
148 fire_triggers(
149 state,
150 identity,
151 tenant_id,
152 collection,
153 &instead_triggers,
154 &bindings,
155 cascade_depth,
156 )
157 .await?;
158
159 Ok(InsteadOfResult::Handled)
160}

Callers 1

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