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_
| 34 | /// - `Some(Async)`: only fire ASYNC triggers (called from Event Plane) |
| 35 | /// - `None`: fire all AFTER triggers regardless of mode (legacy behavior) |
| 36 | pub 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 | /// |
no test coverage detected