isNonEmpty

IsNonEmpty( collection )
IsNonEmpty( collection )
IsNonEmpty( collection )
IsNonEmpty( collection )
is_nonempty( collection )
is_nonempty( collection )
IsNonEmpty( collection )
IsNonEmpty( collection )

Description

The isNonEmpty function returns true only if there is at least one element in the array.

Parameters

Argument Type Definition and Requirements

array

An array which is checked for the existence of elements.

Returns

Returns a boolean.

Examples

The query below executes an array of independent IsNonEmpty operations and returns the results in an array. The result array position matches the execution array position. The first IsNonEmpty operation operates on an empty array and places the result of false in the top position in the result array. The second IsNonEmpty operation operates on an array with a single value of 1 and places the result of true in the second position in the result array. The third IsNonEmpty operation operates on an array with two values and places the result of true in the third position in the result array.

System.out.println(
  client.query(
    Arr(
        IsNonEmpty( Arr()),
        IsNonEmpty( Arr(Value(1))),
        IsNonEmpty( Arr(Value(1), Value(2), Value(3)))
    )
  ).get());
[false, true, true]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!