Distinct
Distinct( set )
Distinct( set )
Distinct( set )
Distinct( set )
distinct( set )
distinct( set )
Distinct( set )
Distinct( set )
Description
The Distinct
function returns a SetRef object that represents all of
the unique elements in the provided SetRef.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
SetRef |
The SetRef to evaluate for distinct elements. |
Examples
The query below show all of the elements in the "elements_of_spells" index. The index contains duplicate values for "fire" and "water".
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{ "paginate": { "match": { "index": "elements_of_spells" } } }'
client.Query(Paginate(Match(Index("elements_of_spells"))));
System.out.println(
client.query(
Paginate(Match(Index(Value("elements_of_spells"))))
).get());
result, _ := client.Query(f.Paginate(f.Match(f.Index("elements_of_spells"))))
fmt.Println(result)
client.query(Paginate(Match(Index("elements_of_spells"))))
client.query(q.paginate(q.match(q.index("elements_of_spells"))))
$client.query do
paginate match(index('elements_of_spells'))
end
client.query(
Paginate(Match(index: Index("elements_of_spells")))
)
client.query(q.Paginate(q.Match(q.Index("elements_of_spells"))))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{
"resource": {
"data": [ "air", "earth", "fire", "fire", "water", "water" ]
}
}
{
"data": [ "air", "earth", "fire", "fire", "water", "water" ]
}
{
data: ["air", "earth", "fire", "fire", "water", "water"]
}
map[data:[air earth fire fire water water]]
{
"data": [ "air", "earth", "fire", "fire", "water", "water" ]
}
{
"data": [ "air", "earth", "fire", "fire", "water", "water" ]
}
{
"data": [ "air", "earth", "fire", "fire", "water", "water" ]
}
{
"data": [ "air", "earth", "fire", "fire", "water", "water" ]
}
{ data: [ 'air', 'earth', 'fire', 'fire', 'water', 'water' ] }
When the set operator Distinct
is applied to this query, the duplicate
values, "fire" and "water" are eliminated.
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{
"paginate": {
"distinct": { "match": { "index": "elements_of_spells" } }
}
}'
client.Query(
Paginate(Distinct(Match(Index("elements_of_spells")))));
System.out.println(
client.query(
Paginate(Distinct(Match(Index(Value("elements_of_spells")))))
).get());
result, _ := client.Query(
f.Paginate(
f.Distinct(f.Match(f.Index("elements_of_spells"))),
),
)
fmt.Println(result)
client.query(
Paginate(Distinct(Match(Index("elements_of_spells")))))
client.query(
q.paginate(q.distinct(q.match(q.index("elements_of_spells")))))
$client.query do
paginate distinct(match(index('elements_of_spells')))
end
client.query(
Paginate(
Distinct(Match(index: Index("elements_of_spells")))
)
)
client.query(q.Paginate(q.Distinct(q.Match(q.Index("elements_of_spells")))))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": { "data": [ "air", "earth", "fire", "water" ] } }
{ "data": [ "air", "earth", "fire", "water" ] }
{ data: ["air", "earth", "fire", "water"] }
map[data:[air earth fire water]]
{ "data": [ "air", "earth", "fire", "water" ] }
{ "data": [ "air", "earth", "fire", "water" ] }
{ "data": [ "air", "earth", "fire", "water" ] }
{ "data": [ "air", "earth", "fire", "water" ] }
{ data: [ 'air', 'earth', 'fire', 'water' ] }
The events view of a set of values include the resources themselves, the
distinct
function returns the same set.
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{
"paginate": {
"distinct": { "match": { "index": "elements_of_spells" } }
},
"events": true
}'
client.Query(
Paginate(
Distinct(Match(Index("elements_of_spells"))),
events: true));
System.out.println(
client.query(
Events(
Paginate(Distinct(Match(Index(Value("elements_of_spells")))))
)
).get());
result, _ := client.Query(
f.Paginate(
f.Events(
f.Distinct(f.Match(f.Index("elements_of_spells"))),
),
),
)
fmt.Println(result)
client.query(
Paginate(
Distinct(Match(Index("elements_of_spells"))),
events = true))
client.query(
q.paginate(
q.distinct(q.match(q.index("elements_of_spells"))),
events=True
))
$client.query do
paginate distinct(match(index('elements_of_spells'))),
events: true
end
client.query(
Paginate(
Distinct(Match(index: Index("elements_of_spells"))),
events: true
)
)
client.query(
q.Paginate(
q.Events(q.Distinct(q.Match(q.Index("elements_of_spells"))))))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{
"resource": {
"data": [
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "air" ]
},
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "water" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "earth" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "water" ]
},
{
"ts": 1509244539709690,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539764856,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
}
]
}
}
{
"data": [
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "air" ]
},
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "water" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "earth" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "water" ]
},
{
"ts": 1509244539709690,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539764856,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
}
]
}
{
data: [
{
ts: 1527267261636139,
action: "add",
instance: ref(id = "181388642071085568", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["fire"]
{
ts: 1527267261636139,
action: "add",
instance: ref(id = "181388642071085568", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["water"]
{
ts: 1527267261664785,
action: "add",
instance: ref(id = "181388642046968320", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["air"]
{
ts: 1527267261664785,
action: "add",
instance: ref(id = "181388642046968320", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["fire"]
{
ts: 1527267261713947,
action: "add",
instance: ref(id = "181388642088911360", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["earth"]
{
ts: 1527267261713947,
action: "add",
instance: ref(id = "181388642088911360", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["water"]
{
ts: 1527267261924953,
action: "add",
instance: ref(id = "181388642581742080", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["air"]
{
ts: 1527267261964739,
action: "remove",
instance: ref(id = "181388642581742080", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["air"]
{
ts: 1527267262013935,
action: "add",
instance: ref(id = "181388642581742080", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["air"]
{
ts: 1527267262062984,
action: "remove",
instance: ref(id = "181388642581742080", class = ref(id = "spells", class = ref(id = "classes"))),
data: ["air"]
}
]
}
map[data:[
map[ts:1509244539203043 action:add instance:{181388642046968320 0xc42026c920 <nil>} data:[air]]
map[ts:1509244539203043 action:add instance:{181388642046968320 0xc42026cc40 <nil>} data:[fire]]
map[ts:1509244539223511 action:add instance:{181388642071085568 0xc42026cf80 <nil>} data:[fire]]
map[ts:1509244539223511 action:add instance:{181388642071085568 0xc42026d2a0 <nil>} data:[water]]
map[ts:1509244539235128 action:add instance:{181388642088911360 0xc42026d5c0 <nil>} data:[earth]]
map[ts:1509244539235128 action:add instance:{181388642088911360 0xc42026d8e0 <nil>} data:[water]]
map[ts:1509244539709690 action:add instance:{181388642581742080 0xc42026dc00 <nil>} data:[air]]
map[ts:1509244539764856 action:add instance:{181388642581742080 0xc42026df20 <nil>} data:[earth]]
map[ts:1509244539795464 action:remove instance:{181388642581742080 0xc420284240 <nil>} data:[air]]
map[ts:1509244539795464 action:remove instance:{181388642581742080 0xc420284560 <nil>} data:[earth]]
]]
{
"data": [
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "air" ]
},
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "water" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "earth" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "water" ]
},
{
"ts": 1509244539709690,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539764856,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
}
]
}
{
"data": [
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "air" ]
},
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "water" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "earth" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "water" ]
},
{
"ts": 1509244539709690,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539764856,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
}
]
}
{
"data": [
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "air" ]
},
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "water" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "earth" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "water" ]
},
{
"ts": 1509244539709690,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539764856,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
}
]
}
{
"data": [
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "air" ]
},
{
"ts": 1509244539203043,
"action": "create",
"resource": { "@ref": "classes/spells/181388642046968320" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "fire" ]
},
{
"ts": 1509244539223511,
"action": "create",
"resource": { "@ref": "classes/spells/181388642071085568" },
"values": [ "water" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "earth" ]
},
{
"ts": 1509244539235128,
"action": "create",
"resource": { "@ref": "classes/spells/181388642088911360" },
"values": [ "water" ]
},
{
"ts": 1509244539709690,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539764856,
"action": "create",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "air" ]
},
{
"ts": 1509244539795464,
"action": "delete",
"resource": { "@ref": "classes/spells/181388642581742080" },
"values": [ "earth" ]
}
]
}
{ data:
[ { ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642046968320, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642046968320, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642071085568, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642071085568, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642088911360, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642088911360, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642581742080, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'add',
instance:
Ref(id=181388642581742080, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'remove',
instance:
Ref(id=181388642581742080, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] },
{ ts: 1527095186458101,
action: 'remove',
instance:
Ref(id=181388642581742080, class=Ref(id=spells, class=Ref(id=classes))),
data: [Array] } ] }
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!