Distinct
Distinct( source )
Description
The Distinct
function returns all of the unique items found in
source
, which can be an Array or Set.
The run time of For query timeout errors, you may specify a larger query timeout via the driver that you are using. |
Examples
The following query shows all of the elements in the "elements_of_spells" index. The index contains duplicate values for "fire" and "water".
{
data: [
'air', 'air',
'earth', 'fire',
'fire', 'water',
'water'
]
}
When the Distinct
function is applied to this query, the duplicate
values, "fire" and "water" are eliminated.
{ data: [ 'air', 'earth', 'fire', 'water' ] }
The events view of a set of values include the resources themselves, the
distinct
function returns the same set.
{
data: [
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642046968320"),
data: [ 'air' ]
},
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642046968320"),
data: [ 'fire' ]
},
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642071085568"),
data: [ 'fire' ]
},
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642071085568"),
data: [ 'water' ]
},
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642088911360"),
data: [ 'earth' ]
},
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642088911360"),
data: [ 'water' ]
},
{
ts: 1592270149090000,
action: 'add',
document: Ref(Collection("spells"), "181388642581742080"),
data: [ 'air' ]
}
]
}
The following query demonstrates how various arrays are evaluated:
[ [ 'A', 'B', 'C' ], [ 'A', 'B' ], [ 'A' ] ]
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!