yii\mongodb\Command::aggregate PHP Method

aggregate() public method

Performs aggregation using MongoDB Aggregation Framework.
public aggregate ( string $collectionName, array $pipelines, array $options = [] ) : array
$collectionName string collection name
$pipelines array list of pipeline operators.
$options array optional parameters.
return array aggregation result.
    public function aggregate($collectionName, $pipelines, $options = [])
    {
        $this->document = $this->db->getQueryBuilder()->aggregate($collectionName, $pipelines, $options);
        $cursor = $this->execute();
        $result = current($cursor->toArray());
        return $result['result'];
    }