0
的支撑件:反应,终极版和Sequelize。 基本上,我希望能够在Redux商店更新时将对象标记为dirty
。非映射属性 - Sequelize
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;
};
任何人谁拥有非映射字段或类似的东西的经历?
你应该接受你自己的答案:) –