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

avg() public method

Returns the average value of 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. $avg ignores non-numeric values.
public avg ( string $field, literal | callable | Sokil\Mongo\Pipeline\Expression $expression ) : GroupStage
$field string
$expression literal | callable | Sokil\Mongo\Pipeline\Expression Expression
return GroupStage
    public function avg($field, $expression)
    {
        $this->stage[$field]['$avg'] = Expression::normalize($expression);
        return $this;
    }