.sum()
Syntax
.sum()
- Returns the sum of the numeric elements of the List or Sequence
.sum{expression}
- Returns the sum of expression, evaluated against each of the elements of the List or Sequence.
Examples
db.job.find{dept:engineering}.sum{baseComp} returns the total base compensation of everyone in the Engineering department.
[1, 2, 3].sum() returns 6
[1, 2, 3].sum{it * 2} returns 12
