Back to top

ReQL command: contains

Command syntax

sequence.contains([value | predicate_function, ...]) → bool

r.contains(sequence, [value | predicate_function, ...]) → bool


When called with values, returns true if a sequence contains all the specified values. When called with predicate functions, returns true if for each predicate there exists at least one element of the stream where that predicate returns true.

Values and predicates may be mixed freely in the argument list.

Example: Has Iron Man ever fought Superman?


Example: Has Iron Man ever defeated Superman in battle?

    battle -> battle.g("winner").eq("ironman").and(

Example: Return all heroes who have fought both Loki and the Hulk.

    hero -> hero.g("opponents").contains("loki", "hulk")

Example: Use contains with a predicate function to simulate an or. Return the Marvel superheroes who live in Detroit, Chicago or Hoboken.

    hero -> r.expr(r.array("Detroit", "Chicago", "Hoboken"))


Get more help

Couldn't find what you were looking for?