Skip to content

Instantly share code, notes, and snippets.

@Sarav-S
Created July 30, 2020 10:27
Show Gist options
  • Save Sarav-S/9efd05d117d1111672efc8ad4b76e0ea to your computer and use it in GitHub Desktop.
Save Sarav-S/9efd05d117d1111672efc8ad4b76e0ea to your computer and use it in GitHub Desktop.
/**
* Marks the path as having pending changes to write to the db.
*
* _Very helpful when using [Mixed](./schematypes.html#mixed) types._
*
* ####Example:
*
* doc.mixed.type = 'changed';
* doc.markModified('mixed.type');
* doc.save() // changes to mixed.type are now persisted
*
* @param {String} path the path to mark modified
* @param {Document} [scope] the scope to run validators with
* @api public
*/
Document.prototype.markModified = function(path, scope) {
this.$__.activePaths.modify(path);
if (scope != null && !this.ownerDocument) {
this.$__.pathsToScopes[path] = scope;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment