Skip to content

Instantly share code, notes, and snippets.

@neumino
Last active January 1, 2016 22:29
Show Gist options
  • Save neumino/8210396 to your computer and use it in GitHub Desktop.
Save neumino/8210396 to your computer and use it in GitHub Desktop.
nelish - IRC - 2013.01.01
r.db('shred').table("teams").map(function(team) {
return team.merge({
members: r.db('shred').table("users").filter(function(user) {
return team("members").contains(user("id"))
}).coerceTo("ARRAY")
})
})
// More efficient query that uses the index id
r.db('shred').table("teams").map(function(team) {
return team.merge({
members: team("members").map( function(memberId) {
return r.db('shred').table("users").get(memberId)
}).coerceTo("ARRAY")
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment