Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Cannot nest schema if setup with plugin #33

Open
wheresvic opened this issue Nov 30, 2016 · 0 comments
Open

Cannot nest schema if setup with plugin #33

wheresvic opened this issue Nov 30, 2016 · 0 comments

Comments

@wheresvic
Copy link
Contributor

wheresvic commented Nov 30, 2016

Hi,

We have a collection which is configured with the history plugin and it works fine. However if I also embed the schema in another collection which also has the history plugin setup, then mongoose-history throws an error on save

TypeError: Cannot read property 'name' of undefined
    at Document.<anonymous> (/xxx/app-name/node_modules/mongoose-history/lib/mongoose-history.js:31:79)

Basically, the save hook thinks that the subdocument also needs to be saved but it is part of a bigger document that has the history plugin setup.

One possible fix could be to check for this.collection before trying to actually save.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant