These are chat archives for Automattic/mongoose

Oct 2017
Paul "Joey" Clark
Oct 14 2017 14:19

@pea The documentation isn't really comprehensive or easy to navigate, but as far as I know it doesn't contain any errors. (I find a lot of details through Google, which leads me to interesting Github issues or Stackoverflow questions.)

I have some suggestions for your code:

  • As pointed out, documents like user don't have a findOneAndUpdate() method, only models like User do.
  • There isn't much point creating a new User() document if you aren't going to save it.
  • You don't really need to set the stravaId since it's guaranteed to have that value already - it was in the find query.
  • If you want to use Promises throughout, then you can remove the err => callback, and instead just return User.findOneAndUpdate(. Then any error would fall to the .catch() and you'll only need that one error handler.
Chris Kacerguis
Oct 14 2017 17:10
Hi all. Would anyone have a few moments to help out with an issue I'm having (been tearing my hair our for a few days). Here's my code:
trying to do a find, and then update based on the results.
however, it never does the update. Would anyone have any ideas?