FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard.

For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions.

IsEmpty

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

IsEmpty( arrayOrSet )
is_empty( array_or_set )
IsEmpty( arrayOrSet )
IsEmpty( arrayOrSet )
IsEmpty( arrayOrSet )
IsEmpty( arrayOrSet )

Description

The IsEmpty function returns true only if there are no items in arrayOrSet.

Parameters

Parameter Type Definition and Requirements

arrayOrSet

Array, Page, or Set

An Array, Page, or Set, which is checked for the non-existence of items.

Returns

Returns a Boolean indicating whether the arrayOrSet value has no items, or not.

Examples

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

client.query([
  q.IsEmpty([]),
  q.IsEmpty([1]),
  q.IsEmpty([1, 2, 3]),
])
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ true, false, false ]
result = client.query([
  q.is_empty([]),
  q.is_empty([1]),
  q.is_empty([1, 2, 3]),
])
print(result)
[True, False, False]
result, err := client.Query(
	f.Arr{
		f.IsEmpty(f.Arr{}),
		f.IsEmpty(f.Arr{1}),
		f.IsEmpty(f.Arr{1, 2, 3}),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[true false false]
try
{
    Value result = await client.Query(
        Arr(
            IsEmpty(Arr()),
            IsEmpty(Arr(1)),
            IsEmpty(Arr(1, 2, 3))
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
Arr(BooleanV(True), BooleanV(False), BooleanV(False))
System.out.println(
    client.query(
        Arr(
            IsEmpty(Arr()),
            IsEmpty(Arr(Value(1))),
            IsEmpty(Arr(Value(1), Value(2), Value(3)))
        )
    ).get());
[true, false, false]
[
  IsEmpty([]),
  IsEmpty([1]),
  IsEmpty([1, 2, 3])
]
[ true, false, false ]
Query metrics:
  •    bytesIn:  55

  •   bytesOut:  31

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:  96

  • writeBytes:   0

  •  queryTime: 5ms

  •    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!