Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Set

Set methods and properties.

Description

A Set represents a group of values, for example, documents in a Collection. When a Set is returned from a query, it is materialized into a page of results that includes a subset of the Set with a pagination cursor.

Lazy vs. Eager loading

To minimize resource consumption, Set methods use lazy loading where possible. These methods defer the materialization of the calling Set and related computations until the data is explicitly needed.

Other Set methods, such as set.includes(), require eager loading. These methods materialize the entire calling Set upfront, even if not all data is returned in the results. For unindexed document Sets, this requires a read of each document in the Set.

Static methods

Method Description

Get a page of paginated results using an after cursor.

Create an ordered Set of Numbers given start and end values.

Create a Set containing a single provided element.

Instance methods

Method Description

Aggregate all elements of a Set.

Test if any element of a Set matches a provided predicate.

A deprecated alias for set.eventsOn().

Concatenate two Sets.

Get the number of elements in a Set.

Get the unique elements of a Set.

Drop the first N elements of a Set.

Create an event source that tracks changes to specified document fields in a supported Set.

Create an event source that tracks changes to documents in a supported Set.

Test if every element of a Set matches a provided predicate.

Get the first element of a Set.

Get the first element of a Set that matches a provided predicate.

Apply a provided function to each Set element and flatten the resulting Set by one level.

Reduce the Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from left to right. Uses a provided seed as the initial value.

Reduce a Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses a provided seed as the initial value.

Run a provided function on each element of a Set. Can perform writes.

Test if the Set includes a provided element.

Test if a Set is empty.

Get the last element of a Set.

Get the last element of a Set that matches a provided predicate.

Apply a provided function to each element of a Set. Can’t perform writes.

Test if a Set is not empty.

Sort a Set's elements.

Set the maximum elements per page in paginated results.

Convert a Set to an Object with pagination.

Reduce a Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from left to right. Uses the first element as the initial value.

Reduce a Set to a single, accumulated value by applying a provided function to each element. Iterates through elements from right to left. Uses the first element as the initial value.

Reverse the order of a Set's elements.

Get the first N elements of a Set.

Convert a Set to an Array.

A deprecated alias for set.eventSource().

Returns the string "[set]".

Get the elements of a Set that match a provided predicate.

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!