These are chat archives for Automattic/mongoose

26th
Apr 2018
Roy Shao
@ycshao
Apr 26 2018 01:30
@lineus that’s a great idea! Let me try that.
panigrah
@panigrah
Apr 26 2018 02:12
Using mongoose for graphql resolvers and looking for a repeatable pattern or libraries that help DRY with validation of input params , checking authorisation, error handling
Roy Shao
@ycshao
Apr 26 2018 03:16
I found a very interest difference between function and arrow function. I don’t understand why it’s different.
userSchema.path('username').validate(function (value) {
  console.debug(this); // when updating, this is query object because I set context to ‘query'
}
vs
userSchema.path('username').validate(value =>  {
  console.debug(this); // this is not query object with everything else the same
}
Kev
@lineus
Apr 26 2018 09:10
@ycshao check out the mdn docs for arrow functions here look for the section on this
Roy Shao
@ycshao
Apr 26 2018 22:42
learnt something new! thanks @lineus