Skip to content

Instantly share code, notes, and snippets.

@neumino
Created August 30, 2013 20:17
Show Gist options
  • Save neumino/6393868 to your computer and use it in GitHub Desktop.
Save neumino/6393868 to your computer and use it in GitHub Desktop.
For RobertZ -- atomic update on condition + return result
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