janez89 / mongoose-materialized

mongoose materialized plugin
59 stars 22 forks source link

setParent only updates the parentId, not the path #31

Open baoyicai opened 7 years ago

baoyicai commented 7 years ago

tried to use the setParent to change the parentId and the path, looks like only the parentId is changed, the actual path is not updated. anyone had the same issue?

Also, wondering if setParent will update the children's paths as well?

janez89 commented 7 years ago

The setParent method only set the parentId from document._id or id. The doc.save() method trigger the path update based on parentId.

https://github.com/janez89/mongoose-materialized#instructions Check the recommended methods section. Only doc.save() / doc.remove() / etc. trigger the path update.