mbouclas / loopback-ds-tree-mixin

Transform a loopback model into a tree using the Array of Ancestors pattern
MIT License
6 stars 4 forks source link

moveNode to itself #9

Closed Jcbobo closed 5 years ago

Jcbobo commented 7 years ago

moving a node to itself is allowed (it should?) but when done multiple time the ancestors is updated adding each time the reference to the note itself

{ "name": "node1", "id": "58ca67bac8e08111d6e3224f", "ancestors": [ "58ca67e1c8e08111d6e32250", "58ca67bac8e08111d6e3224f", "58ca67bac8e08111d6e3224f", "58ca67bac8e08111d6e3224f", "58ca67bac8e08111d6e3224f", "58ca67bac8e08111d6e3224f", "58ca67bac8e08111d6e3224f", "58ca67bac8e08111d6e3224f" ], "parent": "58ca67bac8e08111d6e3224f" }

Jcbobo commented 7 years ago

in the last PR the ancestors array is build each time from scratch so it should not be happen anymore to have multiple time the same id in the ancestors array,

do you think that validation should be inserted for avoid calling moveNode method passing the same node as parent and node?