(node:71307) [DEP0079] DeprecationWarning

前端 未结 8 1701
故里飘歌
故里飘歌 2021-01-17 21:11

Try to update MongoDB document Getting Deprecation Warning as

(node:71307) [DEP0079] DeprecationWarning: Custom inspection function on Objects via

相关标签:
8条回答
  • 2021-01-17 21:38

    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.

    0 讨论(0)
  • 2021-01-17 21:47

    upgrade to 5.2.10 and set

      mongoose.set('useCreateIndex', true);
    
    0 讨论(0)
提交回复
热议问题