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

addToSet() public method

Returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified.
public addToSet ( string $field, literal | callable | Sokil\Mongo\Pipeline\Expression $expression ) : GroupStage
$field string
$expression literal | callable | Sokil\Mongo\Pipeline\Expression Expression
return GroupStage
    public function addToSet($field, $expression)
    {
        $this->stage[$field]['$addToSet'] = Expression::normalize($expression);
        return $this;
    }