my application uses hierarchical data - tree-like structure. I store it in the MongoDB with parent- and children-node references as described in the official documentation. Sadly, there is no mention about how to remove nodes. There are some other tutorials around. but they only consider removing of terminal nodes/leafes.
Consider nodes with following relations
A -> B B -> C B -> D
This will result in an structure like
C / A - B \ D
Removing the the Node B, without reconnecting or removing the nodes C and D will result in orphaned nodes.
I would like to focus on deleting the whole subtree and being able to get reactive changes on the client. So far, I realized I can not use the aggregation framework, cause it is not reactive and does not run on the client. What will be the most efficient way to delete the whole subtree ? I tried to search for recusrsive mongodb query but this usually points to $graphLookup