0
這裏的現有表中現有列的值設置一個新列的值根據使用Sequelize
var Main = sequelize.define('Main', {
id: {
type: Sequelize.INTEGER(100),
allowNull: true
},
status: {
type: Sequelize.INTEGER(100),
allowNull: true
}
});
,我想設置狀態的值等於id + 1的值,我嘗試setter和getter的定義如下,但它不工作:
var Main = sequelize.define('Main', {
id: {
type: Sequelize.INTEGER(100),
allowNull: true
},
status: {
type: Sequelize.INTEGER(100),
allowNull: true,
get: function() {
var num = getDataValue('id');
return num;
},
set: function (val) {
this.setDataValue('status',val+1);
}
}
});
我該怎麼辦?
但地位並沒有改變,我怎樣才能使setter和getter工作? –