janez89 / mongoose-materialized

mongoose materialized plugin
59 stars 22 forks source link

Moving children to a different parent #1

Closed btmdave closed 11 years ago

btmdave commented 11 years ago

Hello,

To move children from one parent to another, would you first get the new parent document, then get all of the children to move, iterate through them and use appendChild with the new parent document. Then use the Remove method to remove from the old parent? Or is there a better method for moving nodes around?

Thanks!

janez89 commented 11 years ago

Hello,

We need keep the structure of children. For this work, need to be call the AppendChild was recursively. The current solution is to (rename the paths)[https://github.com/janez89/mongoose-materialized/blob/master/lib/materialized.js#L143] if necessary. I do not know a better solution.

illustration