reifydb_catalog/store/flow/
delete.rs1use reifydb_core::interface::{CommandTransaction, FlowId, FlowKey, NamespaceFlowKey};
5
6use crate::CatalogStore;
7
8impl CatalogStore {
9 pub async fn delete_flow(txn: &mut impl CommandTransaction, flow_id: FlowId) -> crate::Result<()> {
10 let flow_def = CatalogStore::find_flow(txn, flow_id).await?;
12
13 if let Some(flow) = flow_def {
14 let nodes = CatalogStore::list_flow_nodes_by_flow(txn, flow_id).await?;
16 for node in nodes {
17 CatalogStore::delete_flow_node(txn, node.id).await?;
18 }
19
20 let edges = CatalogStore::list_flow_edges_by_flow(txn, flow_id).await?;
22 for edge in edges {
23 CatalogStore::delete_flow_edge(txn, edge.id).await?;
24 }
25
26 txn.remove(&NamespaceFlowKey::encoded(flow.namespace, flow_id)).await?;
28
29 txn.remove(&FlowKey::encoded(flow_id)).await?;
31 }
32
33 Ok(())
34 }
35}