Created
August 30, 2013 20:17
-
-
Save neumino/6393868 to your computer and use it in GitHub Desktop.
For RobertZ -- atomic update on condition + return result
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
r.db('test').table('test').get(1).update( function(doc) { | |
return r.branch( | |
doc("value").default(0).lt(0), | |
{field: "newValue"}, | |
{} | |
) | |
}, {returnVals: true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment