IsNonEmpty

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

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

Parameter 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 indicating whether the arrayOrSet value contains items or not.

Examples

The following query 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.

try
{
    Value result = await client.Query(
        Arr(
            IsNonEmpty(Arr()),
            IsNonEmpty(Arr(1)),
            IsNonEmpty(Arr(1, 2, 3))
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
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]
client.query([
  q.IsNonEmpty([]),
  q.IsNonEmpty([1]),
  q.IsNonEmpty([1, 2, 3]),
])
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ false, true, true ]
result = client.query([
  q.is_nonempty([]),
  q.is_nonempty([1]),
  q.is_nonempty([1, 2, 3]),
])
print(result)
[False, True, True]
[
  IsNonEmpty([]),
  IsNonEmpty([1]),
  IsNonEmpty([1, 2, 3])
]
[ false, true, true ]
Query metrics:
  •    bytesIn:   64

  •   bytesOut:   30

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    0

  •  readBytes:   96

  • writeBytes:    0

  •  queryTime: 10ms

  •    retries:    0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!