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