Skip to content

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

@stanislau-arkhipenka

Description

@stanislau-arkhipenka

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"]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions