janez89 / mongoose-materialized

mongoose materialized plugin
59 stars 22 forks source link

bulk operations #11

Open mbouclas opened 9 years ago

mbouclas commented 9 years ago

I would like to know what the best solution to handling bulk operations is. For example, a common situation is having a tree on the front end (much like http://dbushell.github.io/Nestable/), the user reorders it and we get a nice array with the entire structure on the backend.

What is the most efficient way to update the existing tree?

DJWassink commented 9 years ago

What I am currently doing, is getting the id of the dragged element and the new parentId it is now under. If you just update the dragged element it's parentId it will recursively update it's children so they will match the path. This way your tree will stay correct.

mbouclas commented 9 years ago

This is what i do as well, but i found my self in a bit of a problem when i had a tree that does not update every time an event occurs, but only when the user presses the save button. In this case, the final tree might have a bunch of changes done to it and what i do is keep something like a changes log and work on that on the backend. The complexity of it though is high and i would like to simplify it somehow

DJWassink commented 9 years ago

I don't think there is currently a solution for this in the plugin yet, The best way to do a operation like that is indeed to keep a list of the changes and process them in your backend. This is however indeed a complex operation. I would recommend to make a request in the missing features post #9 to implement something like this.

mbouclas commented 9 years ago

will do, thanks for the input