/** * Add a "group by" clause to the query. * * @param array|string $column,... * @return $this */ public function groupBy() { foreach (func_get_args() as $arg) { $this->query->group($arg)->ungroup()->map(function ($doc) { return $doc('reduction')->nth(0); }); } return $this; }