Created
December 11, 2013 17:49
-
-
Save brwnll/7915142 to your computer and use it in GitHub Desktop.
Intent: Convert "day" values to Numbers, to be able to run comparison operators against the row.
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
// Data sample | |
[ | |
{ | |
"end": "23:00:00" , | |
"day": "5" , | |
"id": "003b2c9b-fdae-4112-b29b-6081ae138060" , | |
"start": "16:00:00" | |
}, | |
{ | |
"end": "17:00:00" , | |
"day": "6" , | |
"id": "00466316-585f-4578-95ab-99431ed2bece" , | |
"start": "12:00:00" | |
}, | |
{ | |
"end": "18:00:00" , | |
"day": "0" , | |
"id": "067fc39b-2fe8-42d1-a223-533a73998c6b" , | |
"start": "12:00:00" | |
} | |
] | |
// Attempted query | |
r.table("hours") | |
.filter({"id":"003b2c9b-fdae-4112-b29b-6081ae138060"}) | |
.update(function(doc) { return { day : doc("day") + 1 } }) | |
// Result | |
{ | |
"end": "23:00:00" , | |
"day": "var_21("day")1" , | |
"id": "003b2c9b-fdae-4112-b29b-6081ae138060" , | |
"start": "16:00:00" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may want to convert all the
day
fields to number firstAnd then run @mglukhovsky query.
If you want to keep strings for the
day
field, you can use this query: