Created
December 23, 2013 01:45
-
-
Save jakcharlton/8090696 to your computer and use it in GitHub Desktop.
RethinkDB query/update
This file contains hidden or 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.table("foo").get("idValue").update( function(doc) { return r.branch( doc.eq(A), B, {} ) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cyounkins: Is it possible to do a compare-and-swap in Rethink? That is, replace the document with this id with B if it currently equals A.
[12:41pm] neumino: cyounkins, r.table("foo").get("idValue").update( function(doc) { return r.branch( doc.eq(A), B, {} ) })
[12:41pm] neumino: Not that A and B must have the same id since you cannot change the primary key of a document.
[12:42pm] cyounkins: neumino: Thanks! So .eq does a deep compare?
[12:43pm] neumino: cyounkins, yes