I have following schema in SequelizeJS:
var moment = require('moment');
module.exports = function(sequelize, DataTypes) {
var Account = sequelize.define('Account', {
suspended: {
type: DataTypes.BOOLEAN,
defaultValue: false
}
}, {
getterMethods: {
trialDaysLeft: function() {
return 5;
}
},
tableName: 'accounts'
});
return Account;
};
I want to get trialDaysLeft when I call account.trialDaysLeft property.
I am getting
TypeError: Property 'trialDaysLeft' of object [object Object] is not a function
Where am I wrong?
The name might not be the most intuitive but what getterMethods
actually does is generate properties with getter methods on the instance objects.
So in this instance you would need to call instance.trialDaysLeft
and not instance.trialDaysLeft()
(which i'm guessing is what you're doing).