IsNonEmpty

IsNonEmpty( arrayOrSet )
IsNonEmpty( arrayOrSet )
IsNonEmpty( arrayOrSet )
IsNonEmpty( arrayOrSet )
is_nonempty( array_or_set )
IsNonEmpty( arrayOrSet )

Description

The IsNonEmpty function returns true only if there is at least one item in arrayOrSet.

Parameters

Argument Type Definition and Requirements

arrayOrSet

Array, Page, or Set

An array, page, or set, which is checked for the existence of items.

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.

client.Query(
    Arr(
        IsNonEmpty(Arr()),
        IsNonEmpty(Arr(1)),
        IsNonEmpty(Arr(1, 2, 3))
    )
);
Arr(BooleanV(False), BooleanV(True), BooleanV(True))
result, err := client.Query(
	f.Arr{
		f.IsNonEmpty(f.Arr{}),
		f.IsNonEmpty(f.Arr{1}),
		f.IsNonEmpty(f.Arr{1, 2, 3}),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[false true true]
System.out.println(
    client.query(
        Arr(
            IsNonEmpty(Arr()),
            IsNonEmpty(Arr(Value(1))),
            IsNonEmpty(Arr(Value(1), Value(2), Value(3)))
        )
    ).get());
[false, true, true]
client.query([
  q.IsNonEmpty([]),
  q.IsNonEmpty([1]),
  q.IsNonEmpty([1, 2, 3]),
])
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
[ false, true, true ]
result = client.query([
  q.is_nonempty([]),
  q.is_nonempty([1]),
  q.is_nonempty([1, 2, 3]),
])
print(result)
[False, True, True]
println(Await.result(
  client.query(Arr(
    IsNonEmpty(Arr()),
    IsNonEmpty(Arr(1)),
    IsNonEmpty(Arr(1, 2, 3))
  )),
  5.seconds
))
[false, true, true]

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!