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.table('stuff').filter({'this_field' => 'this value'}).grouped_map_reduce( | |
lambda {|doc| doc[:this_other_field]} }, | |
lambda {|doc| [doc] }, | |
lambda {|left, right| left+right} | |
).run(conn) |
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.table("foo").groupedMapReduce( | |
function(doc) { return doc("categorie") }, | |
function(doc) { return doc.pluck("a", "b") }, | |
function(left, right) { | |
return { | |
a: left("a").add(right("a")), | |
b: left("b").add(right("b")) | |
} | |
} | |
).run(...) |
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('marks') | |
.group('name') | |
.concatMap(function(row){return [row('course'), row('mark')];}) | |
.ungroup() | |
.map(function(res){ | |
return r.expr({name: res('group')}) | |
.merge(r.object(r.args(res('reduction')))); | |
}) |
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
// Index: | |
r.table("heroes").indexCreate("idEquipment", function(doc) { | |
return doc("equipment").map(function(equipment) { | |
return [doc("id"), equipment] | |
}) | |
}, {multi: true}).run(conn, callback) | |
// Query | |
r.table("heroes").getAll([1, "boots"], {index: "idEquipment"}).run(conn, callback) |
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
Possibly unhandled TypeError: Cannot call method 'call' of undefined | |
at tryCatch1 (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/util.js:43:21) | |
at CatchFilter$_doFilter [as doFilter] (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/catch_filter.js:80:27) | |
at tryCatch1 (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/util.js:43:21) | |
at Promise$_callHandler [as _callHandler] (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/promise.js:627:13) | |
at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/promise.js:641:18) | |
at Promise$_settlePromiseAt [as _settlePromiseAt] (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/promise.js:800:14) | |
at Promise$_settlePromises [as _settlePromises] (/home/michel/projects/rethinkdb-all/thinky/node_modules/bluebird/js/main/promise.js:934:14) | |
at |
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.expr([{ v: 1 }, { v: 2 }, { v: 3 }, { v: 4 }]).map(function(doc) { | |
return [doc('v')] | |
}).reduce(function(left, right) { | |
return left.union(right).orderBy(function(element) { return element.mul(-1)}).limit(2) | |
}).nth(1) |
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.table('posts').indexStatus('oldIndex').nth(0).do(function(oldIndex) { | |
return r.table('posts').indexCreate('newIndex', oldIndex("function"), {multi: oldIndex("multi")}).do(function() { | |
return r.table('posts').indexWait('newIndex').do(function() { | |
return r.table('posts').indexRename('newIndex', 'oldIndex', {overwrite: true}) | |
}) | |
}) | |
}) |
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.table('story').indexCreate('storyAndId', [r.row("storyAuthor"), r.row("id")] ) | |
var authorId = '1'; | |
r.table('comment').orderBy({index: r.desc('created')}) | |
.eqJoin(function(comment) { | |
return [authorId, comment("parentId")] | |
}, r.table('story'), {index: "storyAndId"}) | |
.limit(20) |
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('foo').update(function(doc) { | |
return doc.merge({foo: {channel: doc("id").add(doc("name")) }}) | |
}) |
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
from pytz import timezone | |
import pickle | |
timezone = timezone('US/Pacific') | |
print timezone | |
f = open('test.txt', 'w') | |
pickle.dump(timezone, f) | |
f.close() |
OlderNewer