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

Function fire_after_insert

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

Fire AFTER ROW triggers for an INSERT operation. Called after a successful INSERT dispatch. `new_fields` contains the inserted row's field values. The trigger body's DML is dispatched through the normal plan+SPSC path, executing in the same logical transaction context. `mode_filter` selects which execution mode to fire: - `Some(Sync)`: only fire SYNC triggers (called from write path) - `Some(Asy

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

Source from the content-addressed store, hash-verified

34/// - `Some(Async)`: only fire ASYNC triggers (called from Event Plane)
35/// - `None`: fire all AFTER triggers regardless of mode (legacy behavior)
36pub async fn fire_after_insert(
37 state: &SharedState,
38 identity: &AuthenticatedIdentity,
39 tenant_id: TenantId,
40 collection: &str,
41 new_fields: &HashMap<String, nodedb_types::Value>,
42 cascade_depth: u32,
43 mode_filter: Option<TriggerExecutionMode>,
44) -> crate::Result<()> {
45 let triggers =
46 state
47 .trigger_registry
48 .get_matching(tenant_id.as_u64(), collection, DmlEvent::Insert);
49
50 let after_triggers: Vec<_> = triggers
51 .into_iter()
52 .filter(|t| t.timing == TriggerTiming::After)
53 .filter(|t| mode_filter.is_none() || Some(t.execution_mode) == mode_filter)
54 .collect();
55
56 if after_triggers.is_empty() {
57 return Ok(());
58 }
59
60 check_cascade_depth(cascade_depth, collection)?;
61
62 let bindings = RowBindings::after_insert(collection, new_fields.clone());
63
64 fire_triggers(
65 state,
66 identity,
67 tenant_id,
68 collection,
69 &after_triggers,
70 &bindings,
71 cascade_depth,
72 )
73 .await
74}
75
76/// Fire AFTER ROW triggers for an UPDATE operation.
77///

Callers 3

fire_sync_after_triggersFunction · 0.85
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