outer_join

ReQL command: outer_join

Command syntax

sequence.outer_join(other_sequence, predicate_function) → stream
array.outer_join(other_sequence, predicate_function) → array

Description

Returns a left outer join of two sequences. The returned sequence represents a union of the left-hand sequence and the right-hand sequence: all documents in the left-hand sequence will be returned, each matched with a document in the right-hand sequence if one satisfies the predicate condition. In most cases, you will want to follow the join with zip to combine the left and right results.

Note that outer_join is slower and much less efficient than using concat_map with get_all. You should avoid using outer_join in commands when possible.

Example: Return a list of all Marvel heroes, paired with any DC heroes who could beat them in a fight.

r.table('marvel').outer_join(r.table('dc')) {|marvel_row, dc_row|
    marvel_row[:strength] < dc_row[:strength]
}.run(conn)

(Compare this to an inner_join with the same inputs and predicate, which would return a list only of the matchups in which the DC hero has the higher strength.)

Related commands

Get more help

Couldn't find what you were looking for?

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/ruby/outer_join/

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部