Hi all, is there a way to do a default value for an aggregate function, e.g. 0 for a sum(children.points) or 0.
Query:
query {
topic(func: eq(id, "1234")) {
id
article(orderdesc: points, orderasc: createdAt) {
id
points: sum(val(p)) # or 0
votes {
id
p as points
createdAt
}
}
}
}
If article has no vote nodes than point is empty and sort doesn’t work. I’d like it to be 0 so sort can put it below others
Hi Jerry, my point is that it should be zero but it’s not. If there are no votes (no child nodes) than instead of zero, the points variable is “missing”. This causes the sort to order incorrectly.
PS. But you should create an automatic process that adds zero to the new user. A simple registration mutation already with the added “zero” would solve this. Do not create blank fields where you need sorting.