You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In official mongoose docs everywhere used `function()` instead of `() => {}`
https://mongoosejs.com/docs/middleware.html#pre
It simply confused me when I've copied code from example and tryed to reach `this` in `.pre('save', () => console.log(this))` there were module itself bcs it loses context. I've spend couple of hours to figure out the issue - it's not that obvious. So my purpose to put `function() {}` there, bcs almost in all cases users will try to do something with document passed to the hook.
0 commit comments