Reputation: 196
Is it possible to pass somethin to myModel.save() for pass validation.
Or, may be, exists special method for it? Somethin like myModel.saveWithoutValidation()
// MyModel.js
module.exports = {
attributes: {
title: {
type: 'string',
minLength: 3,
},
},
};
MyModel.findOne({
id: 31830
}).exec(
function (err, myRecord) {
myRecord.title = 'a'; // it is too short
myRecord.save(function (err, saved) {
if (err) {
console.log(err); // Error (E_VALIDATION)
}
});
});
Upvotes: 1
Views: 149
Reputation: 2881
The short answer is that I don't know any way of passing in an argument that would override the validation.
The slightly longer answer is that you could remove the validation from attributes and do the validation yourself in two different model methods (e.g. myRecord.saveWithValidation(), myRecord.saveWithoutValidation().
Upvotes: 1