Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoose 4: Cannot read property 'apply' of undefined #43

Open
SimoneTaliercio opened this issue Apr 8, 2016 · 3 comments
Open

Mongoose 4: Cannot read property 'apply' of undefined #43

SimoneTaliercio opened this issue Apr 8, 2016 · 3 comments
Labels

Comments

@SimoneTaliercio
Copy link

Hi All :)

I'm fighting with the following error when creating a document with the new operator:

TypeError: Cannot read property 'apply' of undefined
      at q.reduce.post (/Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/lib/document.js:1672:20)
      at Array.reduce (native)
      at model.Document.$__registerHooksFromSchema (/Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/lib/document.js:1670:18)
      at model.Document (/Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/lib/document.js:76:8)
      at model.Model (/Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/lib/model.js:45:12)
      at new model (/Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/lib/model.js:2932:11)
      at /Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/lib/model.js:1744:22
      at /Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/node_modules/async/lib/async.js:570:21
      at /Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/node_modules/async/lib/async.js:249:17
      at /Users/simone/Enviroments/nodejs/target-manager-server/node_modules/mongoose/node_modules/async/lib/async.js:125:13
      at Array.forEach (native)

Since our application is using mongoose-schema-extend I was wondering if you have any tips.

Might it be that mongoose-schema-extend is not compatible with moongoose v.4 ?

Thanks a lot for your help!
Simone

@SimoneTaliercio
Copy link
Author

I have an updated on this. It seems that moongose-extend-schema is working properly till a 3rd level of extension, but at the 4th it breaks. E.g. A <- B <- C is ok, but A <- B <- C <- D is not working.

@sieira
Copy link
Collaborator

sieira commented Apr 16, 2016

I'm marking this as a bug. Unfortunately, I don't have the time to handle this at this moment, sorry

@sieira sieira added the bug label Apr 16, 2016
@SimoneTaliercio
Copy link
Author

SimoneTaliercio commented Apr 16, 2016

Thanks for your reply, sieira. If we can help in anyway then don't hesitate to ask.
I tried to deep dive into both modules (mongoose and yours) but I cannot understand why it breaks. Maybe it is the line where the deep-copy occurs, or maybe is the middleware/hooks from mongoose is changed...
If we would have the expertise to fix it then we would submit a pull request :)

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

No branches or pull requests

2 participants