Hi, I'm not sure if this is by design or not, but I noticed if a model fails validation during save, it is still saved to the cache. I'm using postgres.
Model definition
module.exports = function(db){
var Project = db.define("projects", {
name : String,
created : Date,
project_status : ['active', 'completed', 'on hold', 'dropped']
}, {
methods: {
},
validations: {
project_status: orm.validators.insideList([ 'active', 'completed', 'on hold', 'dropped' ], "Invalid Status")
},
cache: true
});
Project.hasOne('user');
return Project;
};
Save an invalid value to the model.
Project.get(1, function(err, project){
project.project_status = 'foo';
project.save(function(err){
//This will print a validation error
console.log(err);
});
});
Later, retrieving the model will print the invalid value.
Project.get(1, function(err, project){
//This will print 'foo'
console.log(project.project_status);
});
Hi, I'm not sure if this is by design or not, but I noticed if a model fails validation during save, it is still saved to the cache. I'm using postgres.
Model definition
Save an invalid value to the model.
Later, retrieving the model will print the invalid value.