Hello!
I have some problems with creating a dgraph query. I have a scheme:
type Operation {
id: String
amount: int
country: Country
}
type Country {
name: String
}
I want to get a sum of operations where country = ‘UK’ (for example). How i can do this?
When i had written a query like:
query all() {
var(func: type(Operation)) @cascade {
amount as amount
country @filter(eq(name, "UK"))
}
aggregates() {
sum : sum(val(amount))
}
}
I got the sum of total operations, but when I had just done a query with similar parameters (without aggregation) I got a correct list of operations. Suggest me, please, how can I get a correct sum of operations?