Sokil\Mongo\Pipeline\GroupStage::sum PHP Method

sum() public method

Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. $sum ignores non-numeric values.
public sum ( string $field, literal | callable | Sokil\Mongo\Pipeline\Expression $expression ) : GroupStage
$field string
$expression literal | callable | Sokil\Mongo\Pipeline\Expression Expression
return GroupStage
    public function sum($field, $expression)
    {
        $this->stage[$field]['$sum'] = Expression::normalize($expression);
        return $this;
    }