Try to update MongoDB document Getting Deprecation Warning as
(node:71307) [DEP0079] DeprecationWarning: Custom inspection function on Objects via
Totally random but at least it's not a copycat answer: I was getting this deprecation warning (and unexpected behavior) when I accidentally used Model.find()
instead of Model.findOne()
So my erroneous code looked like this
User.find(query)
.then(user => {
console.log(user.emailSettings.confirmToken)
})
...with an ordinary object/array, this would fail with TypeError: Cannot read property 'confirmToken' of undefined
but with an mongo document array apparently it does this inspecty thing and now gives this deprecation warning.
upgrade to 5.2.10 and set
mongoose.set('useCreateIndex', true);