Mongoose model query(findById) error in hooks(pre middleware) due to foreign model Mongoose model query(findById) error in hooks(pre middleware) due to foreign model mongoose mongoose

Mongoose model query(findById) error in hooks(pre middleware) due to foreign model


It has been a while, and I haven't face the same issue so far, so I still don't have a clear solution. But I now see a mistake that could possibly lead to this unexplained behavior. I was concatenating variables or objects in console.log, eg :

console.log('toBeSavedComment : '+ toBeSavedComment) console.log('Protocol : '+ Protocol, 'Type : ' + typeof Protocol)

Instead do use comma "," :

console.log('toBeSavedComment : ', toBeSavedComment) console.log('Protocol : ', Protocol, 'Type : ' , typeof Protocol)

Object concatenation in console.log, for instance, in Amazone Web Service: Elastic Beanstalk prevent the API compilation.

This is not real answer, but I hope this might help!