Storing_TreeView_Structures_WithMongoDB icon indicating copy to clipboard operation
Storing_TreeView_Structures_WithMongoDB copied to clipboard

Broken behavior in case Tree structure Model an Array of Ancestors (update action)

Open stanislau-arkhipenka opened this issue 7 years ago • 1 comments

Hi, In Tree structure Model an Array of Ancestors (update action) in your example in case document "LG" has childs - this code will break structure for them, because you updating list of ancestors for "LG", but do not update list of ancestors for childs of "LG" (and recursively for other sub^n-childs). This will lead to inconsistency of data and ultimately will break it. Example: {"_id":"Electronics"}, {"_id":"Other Electronics"}, {"_id":"LG", "parent":"Electronics", "ancestors":["Electronics"]} {"_id":"LG_phone", "parent":"LG", "ancestors":["Electronics","LG"]}

let's move "LG" from "Electronics" to "Other Electronics" new data will be: {"_id":"Electronics"}, {"_id":"Other Electronics"}, {"_id":"LG", "parent":"Other Electronics", "ancestors":["Other Electronics"]} {"_id":"LG_phone", "parent":"LG", "ancestors":["Electronics","LG"]}

stanislau-arkhipenka avatar Mar 30 '18 14:03 stanislau-arkhipenka

Nice spot. Added to backlog. Feel free to open PR for proper example

Voronenko avatar Apr 01 '18 10:04 Voronenko