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

first() public method

Returns the value that results from applying an expression to the first document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order.
public first ( string $field, literal | callable | Sokil\Mongo\Pipeline\Expression $expression ) : GroupStage
$field string
$expression literal | callable | Sokil\Mongo\Pipeline\Expression Expression
return GroupStage
    public function first($field, $expression)
    {
        $this->stage[$field]['$first'] = Expression::normalize($expression);
        return $this;
    }