node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org ยป



Skip those pesky validations, sometimes.

What it does

This plugin overloads to the following signature:[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:

var validTasks = Tasks.all({invalid: false}, function(err, tasks) {
  // Do something

Usage Example

var SaveInvalid = require('modella-save-invalid');

SaveInvalid.invalidAttr = 'invalid' // Optional, will persist the status into the database
SaveInvalid.completeAttr = 'complete' // Optional, will persist the status into the database, inverse of invalid.

User.use(SaveInvalid); // Assume some model w/ validations.

var user = new User();


// Assume user is still invalid. // Will emit error and not save. {
  err == undefined // Will be false
}); // Will save user in db and user.invalid() will be true, function(err) {
  err == undefined // Will be true (assuming no sync-layer errors)