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

Function fire_instead_of_update

nodedb/src/control/trigger/fire_instead.rs:80–119  ·  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

78/// Check for and fire INSTEAD OF triggers for an UPDATE operation.
79#[allow(clippy::too_many_arguments)]
80pub async fn fire_instead_of_update(
81 state: &SharedState,
82 identity: &AuthenticatedIdentity,
83 tenant_id: TenantId,
84 collection: &str,
85 old_fields: &HashMap<String, nodedb_types::Value>,
86 new_fields: &HashMap<String, nodedb_types::Value>,
87 cascade_depth: u32,
88) -> crate::Result<InsteadOfResult> {
89 let triggers =
90 state
91 .trigger_registry
92 .get_matching(tenant_id.as_u64(), collection, DmlEvent::Update);
93
94 let instead_triggers: Vec<_> = triggers
95 .into_iter()
96 .filter(|t| t.timing == TriggerTiming::InsteadOf)
97 .collect();
98
99 if instead_triggers.is_empty() {
100 return Ok(InsteadOfResult::NoTrigger);
101 }
102
103 check_cascade_depth(cascade_depth, collection)?;
104
105 let bindings = RowBindings::before_update(collection, old_fields.clone(), new_fields.clone());
106
107 fire_triggers(
108 state,
109 identity,
110 tenant_id,
111 collection,
112 &instead_triggers,
113 &bindings,
114 cascade_depth,
115 )
116 .await?;
117
118 Ok(InsteadOfResult::Handled)
119}
120
121/// Check for and fire INSTEAD OF triggers for a DELETE operation.
122pub async fn fire_instead_of_delete(

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