janez89 / mongoose-materialized

mongoose materialized plugin
59 stars 22 forks source link

Possibility to duplicate a tree? #25

Open burakkilic opened 8 years ago

burakkilic commented 8 years ago

Hi;

How can I duplicate a tree? Should I Iterate over the tree? Or any suggestions?

Thanks

janez89 commented 8 years ago

Hello, A possible solution the JSON stringify / parse methods combination.

var object2 = JSON.parse(JSON.stringify(object));
burakkilic commented 8 years ago

But to save the instance, we should remove the _id fields right? I think it won't be easy without iteration.