1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace TBolier\RethinkQL\Query; |
5
|
|
|
|
6
|
|
|
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait; |
7
|
|
|
use TBolier\RethinkQL\Query\Operation\Between; |
8
|
|
|
use TBolier\RethinkQL\Query\Manipulation\HasFields; |
9
|
|
|
use TBolier\RethinkQL\Query\Manipulation\ManipulationTrait; |
10
|
|
|
use TBolier\RethinkQL\Query\Operation\Changes; |
11
|
|
|
use TBolier\RethinkQL\Query\Operation\Get; |
12
|
|
|
use TBolier\RethinkQL\Query\Operation\IndexCreate; |
13
|
|
|
use TBolier\RethinkQL\Query\Operation\IndexDrop; |
14
|
|
|
use TBolier\RethinkQL\Query\Operation\IndexList; |
15
|
|
|
use TBolier\RethinkQL\Query\Operation\IndexRename; |
16
|
|
|
use TBolier\RethinkQL\Query\Operation\OperationTrait; |
17
|
|
|
use TBolier\RethinkQL\Query\Operation\Sync; |
18
|
|
|
use TBolier\RethinkQL\Query\Transformation\TransformationTrait; |
19
|
|
|
use TBolier\RethinkQL\RethinkInterface; |
20
|
|
|
use TBolier\RethinkQL\Types\Term\TermType; |
21
|
|
|
|
22
|
|
|
class Table extends AbstractQuery |
23
|
|
|
{ |
24
|
|
|
use AggregationTrait; |
25
|
11 |
|
use OperationTrait; |
26
|
|
|
use TransformationTrait; |
27
|
11 |
|
|
28
|
|
|
/** |
29
|
11 |
|
* @var array |
30
|
11 |
|
*/ |
31
|
|
|
private $query; |
32
|
11 |
|
|
33
|
11 |
|
public function __construct(string $name, RethinkInterface $rethink) |
34
|
|
|
{ |
35
|
11 |
|
parent::__construct($rethink); |
36
|
|
|
|
37
|
|
|
$this->rethink = $rethink; |
38
|
11 |
|
|
39
|
|
|
|
40
|
|
|
$this->query = [ |
41
|
|
|
TermType::TABLE, |
42
|
|
|
[ |
43
|
2 |
|
$name, |
44
|
|
|
], |
45
|
2 |
|
]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function changes(array $options = null): Changes |
49
|
|
|
{ |
50
|
|
|
return new Changes($this->rethink, $this, $options); |
51
|
11 |
|
} |
52
|
|
|
|
53
|
11 |
|
public function get($key): Get |
54
|
|
|
{ |
55
|
|
|
return new Get($this->rethink, $this, $key); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function indexCreate(string $name): AbstractQuery |
59
|
|
|
{ |
60
|
|
|
return new IndexCreate($this->rethink, $this, $name); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function indexDrop(string $name): AbstractQuery |
64
|
|
|
{ |
65
|
|
|
return new IndexDrop($this->rethink, $this, $name); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function indexList(): AbstractQuery |
69
|
|
|
{ |
70
|
|
|
return new IndexList($this->rethink, $this); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function indexRename(string $oldValue, string $newValue): AbstractQuery |
74
|
|
|
{ |
75
|
|
|
return new IndexRename($this->rethink, $this, $oldValue, $newValue); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function between($min, $max, array $options = null): Between |
79
|
|
|
{ |
80
|
|
|
return new Between($this->rethink, $this, $min, $max, $options); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function hasFields(...$keys) |
84
|
|
|
{ |
85
|
|
|
return new HasFields($this->rethink, $this, $keys); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function sync() |
89
|
|
|
{ |
90
|
|
|
return new Sync($this->rethink, $this); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function toArray(): array |
94
|
|
|
{ |
95
|
|
|
return $this->query; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|