Any

Not available in this language yet.
Not available in this language yet.
Any( values )
Any( values )
Not available in this language yet.
Any( values )

The run time of Any is dependent on the number of elements in the underlying set or page — it’s linear, or O(n). For very large sets or pages, executing Any might result in a query timeout error.

To work around this, you may specify a larger query timeout via the driver that you are using.

Description

The Any function tests the provided values and returns true if any of the items in values is true, otherwise it returns false.

When values is an empty Array or Set, Any returns false, because values contains no true values.

Any is a better choice for handling collections of values than the similar Or function.

Parameters

Argument Type Definition and Requirements

values

Array or Set

A group of values to test for being true.

Returns

A boolean indicating whether any of the items in values is true.

Examples

The following query uses Any multiple times to demonstrate how the function evaluates several groups of values:

Not available in this language yet.
Not available in this language yet.
System.out.println(
    client.query(
        Arr(
            Any(Arr(Value(true), Value(true), Value(true))),
            Any(Arr(Value(false), Value(true), Value(true))),
            Any(Arr(Value(false), Value(false), Value(false))),
            Any(Arr())
        )
    ).get());
[true, true, false, false]
client.query([
  q.Any([true, true, true]),
  q.Any([false, true, true]),
  q.Any([false, false, false]),
  q.Any([]),
])
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
[ true, true, false, false ]
Not available in this language yet.
println(Await.result(
  client.query(
    Arr(
      Any(Arr(true, true, true)),
      Any(Arr(false, true, true)),
      Any(Arr(false, false, false)),
      Any(Arr())
    )
  ),
  5.seconds
))
[true, true, false, false]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!