|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
|
|
4
|
|
|
namespace TBolier\RethinkQL\Query\Aggregation; |
|
5
|
|
|
|
|
6
|
|
|
use TBolier\RethinkQL\Query\AbstractQuery; |
|
7
|
|
|
use TBolier\RethinkQL\Query\QueryInterface; |
|
8
|
|
|
use TBolier\RethinkQL\Query\Transformation\TransformationCompoundInterface; |
|
9
|
|
|
|
|
10
|
|
|
abstract class AbstractAggregation extends AbstractQuery implements AggregationInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @inheritdoc |
|
14
|
|
|
*/ |
|
15
|
|
|
public function count(): QueryInterface |
|
16
|
|
|
{ |
|
17
|
|
|
return new Count($this->rethink, $this->message, $this); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @inheritdoc |
|
22
|
|
|
*/ |
|
23
|
|
|
public function group(string $key): TransformationCompoundInterface |
|
24
|
|
|
{ |
|
25
|
|
|
return new Group($this->rethink, $this->message, $this, $key); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @inheritdoc |
|
30
|
|
|
*/ |
|
31
|
|
|
public function ungroup(): TransformationCompoundInterface |
|
32
|
|
|
{ |
|
33
|
|
|
return new Ungroup($this->rethink, $this->message, $this); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @inheritdoc |
|
38
|
|
|
*/ |
|
39
|
|
|
public function sum(string $key): QueryInterface |
|
40
|
|
|
{ |
|
41
|
|
|
return new Sum($this->rethink, $this->message, $this, $key); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @inheritdoc |
|
46
|
|
|
*/ |
|
47
|
|
|
public function avg(string $key): QueryInterface |
|
48
|
|
|
{ |
|
49
|
|
|
return new Avg($this->rethink, $this->message, $this, $key); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @inheritdoc |
|
54
|
|
|
*/ |
|
55
|
|
|
public function min(string $key): AggregationInterface |
|
56
|
|
|
{ |
|
57
|
|
|
return new Min($this->rethink, $this->message, $this, $key); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @inheritdoc |
|
62
|
|
|
*/ |
|
63
|
|
|
public function max(string $key): TransformationCompoundInterface |
|
64
|
|
|
{ |
|
65
|
|
|
return new Max($this->rethink, $this->message, $this, $key); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|