Last active
January 1, 2016 22:29
-
-
Save neumino/8210396 to your computer and use it in GitHub Desktop.
nelish - IRC - 2013.01.01
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.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