I donβt know, someone is still running this error, but if you have any problems with this, here is how I solved the problem.
I had a similar situation when I had a UserModel object that looked like this:
var UserModel = sequelize.define("users", { ID: { type: Sequelize.INTEGER, field: "ID", primaryKey: true, autoIncrement: true }, Username: { type: Sequelize.STRING, field: "Username" }, Password: { type: Sequelize.STRING, field: "Password" }, Sector: { type: Sequelize.INTEGER, field: "Sector" }, SubSector: { type: Sequelize.INTEGER, field: "SubSector" }, Email: { type: Sequelize.STRING, field: "email" }, Status: { type: Sequelize.INTEGER, field: "status" } }
And my setters and getters:
{ getterMethods: { Sector: function() { return this.Sector; }, Status: function() { return this.Status; } }, setterMethods: { Sector: function(val) { this.setDataValue('Sector',val); }, Status: function(val) { this.setDataValue('Status',val); } } });
And of course, I had a stack error.
To solve this problem, I just changed the settings and recipients:
{ getterMethods: { currSector: function() { return this.Sector; }, currStatus: function() { return this.Status; } }, setterMethods: { newSector: function(val) { this.setDataValue('Sector',val); }, newStatus: function(val) { this.setDataValue('Status',val); } } });
And everything went magically, despite the fact that in many examples online I saw people offering the approach of providing the same setter / getter name as the fields.
So, in a nutshell, changing the name of the setters and getters so that their name does not match any of the specific fields that solved my problem. Good practice? I'm not sure, but he solved my problem.