Closed xiaofan2406 closed 8 years ago
With Node js moving to es6, it would be great if arrow function works when defining instanceMethods.
module.exports = (sequelize, DataTypes) => { const User = sequelize.define('User', { name: DataTypes.STRING }, { instanceMethods: { foo: () => { // this is not gonna work as expected return this.name } } }); return User; };
above code to work.
I may be wrong. I think the lexical scoping is not working in our favor here.
There is no way to override the scope of arrow functions - that's one of their main features. So there's nothing we can do here
can you elaborate why this thing is happening!!! @janmeier
What you are doing?
With Node js moving to es6, it would be great if arrow function works when defining instanceMethods.
What do you expect to happen?
above code to work.
What is actually happening?
I may be wrong. I think the lexical scoping is not working in our favor here.