支持是:React、Redux 和 Sequelize。基本上我希望能够dirty
在 Redux 存储更新时将对象标记为存在。
function updateCar(carToUpdate, car) {
switch(car[1]) {
case "models":
carToUpdate.models = car[3];
carToUpdate.setDirty();
break;
}
};
然后当有人单击保存按钮时,我只想更新那些将脏标志设置为 true 的模型
var state = request.body;
state.forEach(function (car) {
if (car && car.isDirty) {
updateCar(car);
}
}
现在我有以下汽车型号:
module.exports = function (sequelize, DataTypes) {
var Cars = sequelize.define('Cars',
{
name: DataTypes.STRING,
type: DataTypes.INTEGER,
models: DataTypes.INTEGER,
//Next is NOT working, this does not make it non-mapped
isDirty: {
type: DataTypes.BOOLEAN,
scope: false
},
},
{
classMethods: {
associate: function (models) {
// associations can be defined here
}
},
instanceMethods: {
setDirty: function() {
this.isDirty = true;
}
}
});
return Cars;
};
任何有非映射字段或类似经验的人?