Created
October 24, 2016 01:54
-
-
Save pchw/9c13a5d62da0a499f111a4f48fd1b579 to your computer and use it in GitHub Desktop.
reversible state converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = | |
converter: (targetObjs, beforeObj, afterObj, isCheckBefore, isReverse, callback)-> | |
if isReverse | |
if isCheckBefore | |
conditions = _.merge {}, afterObj | |
updates = _.merge {}, beforeObj | |
else | |
if isCheckBefore | |
conditions = _.merge {}, beforeObj | |
updates = _.merge {}, afterObj | |
conditions[$isolated] = true | |
conditions._id = | |
$in: _.map targetObjs, '_id' | |
Documnt.update conditions, updates, | |
$multi: true | |
, callback |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment