yii\mongodb\Query::sum PHP Method

sum() public method

Returns the sum of the specified column values.
public sum ( string $q, Connection $db = null ) : integer
$q string the column name. Make sure you properly quote column names in the expression.
$db Connection the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used.
return integer the sum of the specified column values
    public function sum($q, $db = null)
    {
        return $this->aggregate($q, 'sum', $db);
    }