Behavior of this variable in Validation with Mongoose + Nodejs

-1

I'm trying to run a validation process for a field in the mongoose schema. However, the behavior of the "this" variable is different than expected. Well, according to the documentation at link , you should refer to the model object you are being saved. However, when debugging in VsCode the Local reference to this is correct, however, the reference pointed to by the "Watcher" is another, the class reference of the module. Can anyone tell me why this occurs? How do I access the correct this reference in this context?

    
asked by anonymous 25.07.2018 / 17:35

1 answer

0

Reply posted on: link

You can not use Arrow functions to access this context.

    
26.07.2018 / 00:40