Skip to content

Commit

Permalink
feat(document): add $ignore to make a path ignored
Browse files Browse the repository at this point in the history
Re: #4480
  • Loading branch information
vkarpov15 committed Sep 18, 2016
1 parent bc51e33 commit dc231db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 17 additions & 0 deletions lib/document.js
Expand Up @@ -962,6 +962,23 @@ Document.prototype.unmarkModified = function(path) {
this.$__.activePaths.init(path);
};

/**
* Don't run validation on this path or persist changes to this path.
*
* ####Example:
*
* doc.foo = null;
* doc.$ignore('foo');
* doc.save() // changes to foo will not be persisted and validators won't be run
*
* @param {String} path the path to ignore
* @api public
*/

Document.prototype.$ignore = function(path) {
this.$__.activePaths.ignore(path);
};

/**
* Returns the list of paths that have been modified.
*
Expand Down
2 changes: 0 additions & 2 deletions test/document.modified.test.js
Expand Up @@ -514,7 +514,6 @@ describe('document modified', function() {
});
});


it('should reset the modified state after calling unmarkModified', function(done) {
var db = start();
var BlogPost = db.model(modelName, collection);
Expand Down Expand Up @@ -556,6 +555,5 @@ describe('document modified', function() {
});
});
});

});
});

0 comments on commit dc231db

Please sign in to comment.