distinct()

Signature

distinct(): Set

Description

The distinct() method returns the unique elements of an ordered set.

The distinct() method can be used on the results returned by an index provided the result set isn’t reordered and map() or flatMap() havn’t been called on the set. It can also be used to sort array fields in a document. Because field arrays are limited to the maximum document size of 8 MB, they need not be presorted before calling distinct().

There is no limit on the size of the set that the distinct() method can be run on.

The source set isn’t changed.

Parameters

None

Return value

Type Description

Set

Unique elements in the set.

Examples

[1, 1, 2, 3, 3].distinct()
[
  1,
  2,
  3
]

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!