Skip to content

Latest commit

 

History

History
56 lines (42 loc) · 1.32 KB

or.md

File metadata and controls

56 lines (42 loc) · 1.32 KB
layout language permalink command related_commands
api-command
Python
api/python/or/
|, or_
&, and_ ==, eq !=, ne
and/
eq/
ne/

Command syntax

{% apibody %} bool | bool → bool bool.or_([bool, bool, ...]) → bool r.or_([bool, bool, ...]) → bool {% endapibody %}

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)). The standard Python or operator, |, may also be used with ReQL.

Calling or_ with zero arguments will return False.

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

> a = True
> b = False
> (r.expr(a) | b).run(conn)

True

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

> x = False
> y = False
> z = False
> r.or_(x, y, z).run(conn)

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(lambda post:
    post['category'].default('foo').eq('article').or(
        post['genre'].default('foo').eq('mystery'))
).run(conn)