Reputation: 1
`
datastore.aggregate()
.match()
.project()
.unwind()
.group(group(id("my_id")).field("totalCount", sum("1")).field("average", avg(field("field2"))))
.execute(result::class.java)
.toList()
`
In CLI it works something like $sum : 1 in group to do a count(*) but how to do this in kotlin/java code??
I just want to count all occurences after group by . Basically similar to select count(*) from table group by name;
Upvotes: 0
Views: 170
Reputation: 1
UPDATE: Got through the docs after investing hours. We can use sum(literal(1))
to do the same in aggregation query in kotlin.
Upvotes: 0