ReQL command: or

Command syntax

bool.or([bool, bool, ...]) → bool
r.or([bool, bool, ...]) → bool

Description

Compute the logical “or” of one or more values.

The or command can be used as an infix operator after its first argument (r.expr(true).or(false)) or given all of its arguments as parameters (r.or(true,false)).

Calling or with zero arguments will return false.

Example: Return whether either a or b evaluate to true.

var a = true, b = false;
r.expr(a).or(b).run(conn, callback);
// result passed to callback
true

Example: Return whether any of x, y or z evaluate to true.

var x = false, y = false, z = false;
r.or(x, y, z).run(conn, callback);
// result passed to callback
false

Note: When using or inside a filter predicate to test the values of fields that may not exist on the documents being tested, you should use the default command with those fields so they explicitly return false.

r.table('posts').filter(
    r.row('category').default('foo').eq('article').
    or(r.row('genre').default('foo').eq('mystery'))
).run(conn, callback);

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