Last active
July 22, 2016 11:59
-
-
Save brandon-beacher/0b684f471a4e279dc77e to your computer and use it in GitHub Desktop.
left outer join in RethinkDB using javascript syntax
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("gather").table("contacts").filter({Company: "yiq5yon7"}).concatMap(function(contact) { | |
return r.db("gather").table("accounts").getAll(contact("Account").default("")).coerceTo("array").do(function(accounts) { | |
return r.branch( | |
accounts.isEmpty(), | |
[ { left: contact, right: null } ], | |
accounts.map(function(account) { | |
return { left: contact, right: account } | |
}) | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! This totally helped, because the official docs (here https://www.rethinkdb.com/docs/sql-to-reql/javascript/) weren't working.