Hi I'm using javascript with rethinkdb, and I'm trying to figure out how to use eqJoin when the id of the target is not on the maintable but on the second table.
The examples on the website shows this.
first table /players
[{name: 'anna', gameID:1}]
second table /games
[{id: 1, gameName: 'supergame'}]
But what I want to join is this
first table / players
[{id 1, name: 'anna'}]
second table / games
[{playerID: 1, gameName:'supergame'},
{playerID: 1, gameName:'megagame'},
{playerID: 1, gameName:'lamegame'}]
I have read a little about concatMap and tried this but that obviously gives me errors, is there any other way?
And if there is could I even join even more tables?
r.table("players").concatMap(function(play) {
return r.table("games").getAll(
play("id"),
{ index:"playerID" }
).map(function(games) {
return { left: play, right: games }
})
}).run(conn, callback)