Add sum() Flux function + docs
Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
parent
ee0ae4ca20
commit
2257e4f9cd
6 changed files with 108 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ use Arendsen\FluxQueryBuilder\Functions\Group;
|
|||
use Arendsen\FluxQueryBuilder\Functions\Limit;
|
||||
use Arendsen\FluxQueryBuilder\Functions\Mean;
|
||||
use Arendsen\FluxQueryBuilder\Functions\Window;
|
||||
use Arendsen\FluxQueryBuilder\Functions\Sum;
|
||||
|
||||
trait Universe
|
||||
{
|
||||
|
|
@ -94,4 +95,12 @@ trait Universe
|
|||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addSum(string $column): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
new Sum($column)
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/Functions/Sum.php
Normal file
21
src/Functions/Sum.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Arendsen\FluxQueryBuilder\Functions;
|
||||
|
||||
class Sum extends Base
|
||||
{
|
||||
/**
|
||||
* @var string $column
|
||||
*/
|
||||
private $column;
|
||||
|
||||
public function __construct(string $column)
|
||||
{
|
||||
$this->column = $column;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return '|> sum(column: "' . (string)$this->column . '") ';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue