Entity adapters: Managing nested relationships and cascading deletes
0 reputation · 08 Aug 2020, 13:11 UTC
Goal
To keep a normalized state that reflects a parent-child relationship between two entity collections while ensuring that deleting a parent automatically removes its children from the store.
Constraints
The @ngrx/entity library offers adapters that generate CRUD reducers and selectors, but it does not provide a built‑in mechanism for nested or parent‑child relationships. A sortComparer that returns 0 for equal values can lead to unstable ordering across updates, which complicates maintaining consistent relationships.
Unresolved Decision
Given these constraints, the team needs to decide how to implement cascading deletes and maintain referential integrity without breaking the immutable update guarantees of the store.
Questions
- What patterns or helper utilities are recommended for cascading deletes when using ngrx Entity?
- Is there an official or widely accepted approach to linking parent and child entities within the store?
- How can we guarantee that the relative order of entities remains stable when the sortComparer is non‑strict?