What I want to do
here’s the schema:
type Persion {
name
friends
nationality
}
type Country {
name
}
and sample data:
_:a <dgraph.type> "Persion" .
_:a <name> "A" .
_:b <dgraph.type> "Persion" .
_:b <name> "B" .
_:c <dgraph.type> "Persion" .
_:c <name> "C" .
_:y <dgraph.type> "Country" .
_:y <name> "Y" .
_:z <dgraph.type> "Country" .
_:z <name> "Z" .
_:a <friends> _:b .
_:a <friends> _:c .
_:b <friends> _:c .
_:b <friends> _:a .
_:a <nationality> _:z .
_:b <nationality> _:y .
_:c <nationality> _:y .
What I did
Query who knows people from more than two countries.
I’ve tried many queries but none get work, here’s is one of my queries:
{
q(func: eq(dgraph.type, "Persion")) @filter(ge(cs, 2) @cascade{
name
cs as count(friends.nationality)
friends {
name
nationality {
name
}
}
}
}
Expected results:
{
"name": "B",
"friends":[
{
"name": "A",
"nationality": {
"name": "Z",
}
},
{
"name": "C",
"nationality": {
"name": "Y",
}
}
]
}
What did I missunderstanding? Any suggestions?
Dgraph version : v20.11.3