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
Fat arrow in ES6 binds this to the lexical scope, which is just a fancy way of saying that this inside an arrow function is the same as outside the arrow function. Use User.pre('save', function(next) {}); instead.
Unfortunately not atm, pre hooks explicitly rely on passing the document through this rather than as a parameter. Fat arrows won't work with this paradigm.
There is a problem with the pre save hook where 'this' should give me the document being saved but it gives undefined instead.
What could possibly be the error?
P.S.: It saves normally when the pre hook being is not used.
The text was updated successfully, but these errors were encountered: