Last active
May 4, 2016 20:46
-
-
Save avanslaars/b836699325322277180debb8ea2d963e to your computer and use it in GitHub Desktop.
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('demo').table('people') | |
.eqJoin('id', r.db('demo').table('pets'), {index:'owner_id'}) | |
.group('left') | |
.pluck('right') | |
.ungroup() | |
.map(group => ({ | |
person: group('group'), | |
pets: group('reduction').map(pet => pet('right')) | |
})) |
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('demo').table('people').innerJoin(r.db('demo').table('pets'), (personRow, petRow) => personRow('id').eq(petRow('owner_id'))) |
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('demo').table('people').outerJoin(r.db('demo').table('pets'), (personRow, petRow) => personRow('id').eq(petRow('owner_id'))) | |
/* | |
optional group, zip and pluck to get to the specifics of the pet | |
.group('left').zip().pluck('name', 'type') | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment