You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This plugin overloads model.save to the following signature: model.save([skipValidations], cb). With out a boolean as
the first argument, the behavior is identical to modella's default.
With the additional flag, it will skip validations. Optionally if SaveInvalid.invalidAttr or SaveInvalid.completeAttr is set, an invalid model will have
that attribute persisted as well. This is useful so that you can only query for valid models. E.g:
varvalidTasks=Tasks.all({invalid: false},function(err,tasks){// Do something});
Usage Example
varSaveInvalid=require('modella-save-invalid');SaveInvalid.invalidAttr='invalid'// Optional, will persist the status into the databaseSaveInvalid.completeAttr='complete'// Optional, will persist the status into the database, inverse of invalid.User.use(SaveInvalid);// Assume some model w/ validations.varuser=newUser();user.username('Bobby');// Assume user is still invalid.user.save()// Will emit error and not save.user.save(function(err){err==undefined// Will be false});user.save(true)// Will save user in db and user.invalid() will be trueuser.save(true,function(err){err==undefined// Will be true (assuming no sync-layer errors)});