RethinkDB: LEFT JOIN Example

In RethinkDB, a LEFT JOIN looks exactly like INNER JOIN:

r.db('test')
 .table('user_actions')
 .outerJoin(r.table('users'),
    (action, user) => 
      action('user_id').eq(user('id')))
 .zip()

A couple notes here: to achieve an expected result you need to add “.zip” at the end, otherwise you get a data structure with “left” and “right”.

It’s also important to note that despite the name this is actually a left join. If you want to do a right join, you need to swap the arguments to the function. If you want full outer join, you’ll need to do left and right joins, then union the results.