Hi, I have query:
{
countryInfo(func: eq(user.id, ["idA", "idB", "idC"])) {
user.id
countries as user.friends {
~country.friends {
uid
}
}
val(countries)
}
}
Response:
{
"data": {
"countryInfo": [
{
"user.id": "idA",
"countries": [
{
"~country.friends": [
{
"uid": "0x169a49"
},
{
"uid": "0x169a48"
}
]
},
{
"~country.friends": [
{
"uid": "0x169a48"
},
{
"uid": "0x169a49"
}
]
},
{
"~country.friends": [
{
"uid": "0x169a48"
}
]
}
]
},
{
"user.id": "idB",
"countries": [
{
"~country.friends": [
{
"uid": "0x169a4b"
}
]
}
]
},
{
"user.id": "idC",
"countries": [
{
"~country.friends": [
{
"uid": "0x169a4b"
},
{
"uid": "0x169ba3"
},
{
"uid": "0x169ba4"
}
]
}
]
}
]
}
}
But I only need to calculate the unique countries for each “user.id”, how can I do that?
I need response
{
"data": {
"countryInfo": [
{
"user.id": "idA",
"uniqueCountries": 2
},
{
"user.id": "idB",
"uniqueCountries": 1
},
{
"user.id": "idC",
"uniqueCountries": 3
}
]
}
]
}
}
Thank you