tbolier /
php-rethink-ql
| 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\Operation\Get; |
||
| 9 | use TBolier\RethinkQL\Query\Operation\IndexCreate; |
||
| 10 | use TBolier\RethinkQL\Query\Operation\IndexDrop; |
||
| 11 | use TBolier\RethinkQL\Query\Operation\IndexList; |
||
| 12 | use TBolier\RethinkQL\Query\Operation\IndexRename; |
||
| 13 | use TBolier\RethinkQL\Query\Operation\OperationTrait; |
||
| 14 | use TBolier\RethinkQL\Query\Transformation\TransformationTrait; |
||
| 15 | use TBolier\RethinkQL\RethinkInterface; |
||
| 16 | use TBolier\RethinkQL\Types\Term\TermType; |
||
| 17 | |||
| 18 | class Table extends AbstractQuery |
||
| 19 | { |
||
| 20 | use AggregationTrait; |
||
| 21 | use OperationTrait; |
||
| 22 | use TransformationTrait; |
||
| 23 | |||
| 24 | /** |
||
| 25 | 11 | * @var array |
|
| 26 | */ |
||
| 27 | 11 | private $query; |
|
| 28 | |||
| 29 | 11 | public function __construct(string $name, RethinkInterface $rethink) |
|
| 30 | 11 | { |
|
| 31 | parent::__construct($rethink); |
||
| 32 | 11 | ||
| 33 | 11 | $this->rethink = $rethink; |
|
| 34 | |||
| 35 | 11 | ||
| 36 | $this->query = [ |
||
| 37 | TermType::TABLE, |
||
| 38 | 11 | [ |
|
| 39 | $name, |
||
| 40 | ], |
||
| 41 | ]; |
||
| 42 | } |
||
| 43 | 2 | ||
| 44 | public function get($key): AbstractQuery |
||
| 45 | 2 | { |
|
| 46 | return new Get($this->rethink, $this, $key); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function indexCreate(string $name): AbstractQuery |
||
| 50 | { |
||
| 51 | 11 | return new IndexCreate($this->rethink, $this, $name); |
|
| 52 | } |
||
| 53 | 11 | ||
| 54 | public function indexDrop(string $name): AbstractQuery |
||
| 55 | { |
||
| 56 | return new IndexDrop($this->rethink, $this, $name); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function indexList(): AbstractQuery |
||
| 60 | { |
||
| 61 | return new IndexList($this->rethink, $this); |
||
| 62 | } |
||
| 63 | |||
| 64 | public function indexRename(string $oldValue, string $newValue): AbstractQuery |
||
| 65 | { |
||
| 66 | return new IndexRename($this->rethink, $this, $oldValue, $newValue); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function between( |
||
| 70 | $min, |
||
| 71 | $max, |
||
| 72 | $options = null |
||
| 73 | ): AbstractQuery |
||
| 74 | { |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 75 | return new Between( |
||
| 76 | $this->rethink, |
||
| 77 | $this, |
||
| 78 | $min, |
||
| 79 | $max, |
||
| 80 | $options |
||
| 81 | ); |
||
| 82 | } |
||
| 83 | |||
| 84 | public function toArray(): array |
||
| 85 | { |
||
| 86 | return $this->query; |
||
| 87 | } |
||
| 88 | } |
||
| 89 |