| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Rethinkdb::Query::Table; |
|
2
|
15
|
|
|
15
|
|
51
|
use Rethinkdb::Base 'Rethinkdb::Query'; |
|
|
15
|
|
|
|
|
20
|
|
|
|
15
|
|
|
|
|
84
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
15
|
|
|
15
|
|
65
|
use Carp qw'croak carp'; |
|
|
15
|
|
|
|
|
22
|
|
|
|
15
|
|
|
|
|
707
|
|
|
5
|
15
|
|
|
15
|
|
58
|
use Scalar::Util 'weaken'; |
|
|
15
|
|
|
|
|
17
|
|
|
|
15
|
|
|
|
|
477
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
57
|
use Rethinkdb::Protocol; |
|
|
15
|
|
|
|
|
17
|
|
|
|
15
|
|
|
|
|
71
|
|
|
8
|
15
|
|
|
15
|
|
4655
|
use Rethinkdb::Util; |
|
|
15
|
|
|
|
|
22
|
|
|
|
15
|
|
|
|
|
110
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has [qw{ _rdb name }]; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# primary_key = None |
|
13
|
|
|
|
|
|
|
# datacenter = None |
|
14
|
|
|
|
|
|
|
# durability = hard|soft |
|
15
|
|
|
|
|
|
|
# cache_size = '1024MB' |
|
16
|
|
|
|
|
|
|
sub create { |
|
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
18
|
0
|
0
|
|
|
|
|
my $optargs = ref $_[0] ? $_[0] : {@_}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
21
|
|
|
|
|
|
|
_rdb => $self->_rdb, |
|
22
|
|
|
|
|
|
|
_type => $self->_termType->table_create, |
|
23
|
|
|
|
|
|
|
args => $self->name, |
|
24
|
|
|
|
|
|
|
optargs => $optargs, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
weaken $q->{_rdb}; |
|
28
|
0
|
|
|
|
|
|
return $q; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub drop { |
|
32
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
35
|
|
|
|
|
|
|
_rdb => $self->_rdb, |
|
36
|
|
|
|
|
|
|
_type => $self->_termType->table_drop, |
|
37
|
|
|
|
|
|
|
args => $self->name, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
weaken $q->{_rdb}; |
|
41
|
0
|
|
|
|
|
|
return $q; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub index_create { |
|
45
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
46
|
0
|
|
|
|
|
|
my $args = shift; |
|
47
|
0
|
0
|
|
|
|
|
my $optargs = ref $_[0] ? $_[0] : {@_}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ( ref $optargs ne 'HASH' ) { |
|
|
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$args = [ $args, Rethinkdb::Util->_wrap_func($optargs) ]; |
|
51
|
0
|
|
|
|
|
|
$optargs = undef; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
elsif ( $optargs->{'$reql_type$'} ) { |
|
54
|
0
|
|
|
|
|
|
$args = [ $args, $optargs ]; |
|
55
|
0
|
|
|
|
|
|
$optargs = undef; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
59
|
|
|
|
|
|
|
_parent => $self, |
|
60
|
|
|
|
|
|
|
_type => $self->_termType->index_create, |
|
61
|
|
|
|
|
|
|
args => $args, |
|
62
|
|
|
|
|
|
|
optargs => $optargs, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $q; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub index_drop { |
|
69
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
|
my $index = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
73
|
|
|
|
|
|
|
_parent => $self, |
|
74
|
|
|
|
|
|
|
_type => $self->_termType->index_drop, |
|
75
|
|
|
|
|
|
|
args => $index |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $q; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub index_list { |
|
82
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
85
|
|
|
|
|
|
|
_parent => $self, |
|
86
|
|
|
|
|
|
|
_type => $self->_termType->index_list, |
|
87
|
|
|
|
|
|
|
); |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return $q; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub index_rename { |
|
93
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
94
|
0
|
|
|
|
|
|
my $args = [@_]; |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
97
|
|
|
|
|
|
|
_parent => $self, |
|
98
|
|
|
|
|
|
|
_type => $self->_termType->index_rename, |
|
99
|
|
|
|
|
|
|
args => $args |
|
100
|
|
|
|
|
|
|
); |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $q; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub index_status { |
|
106
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
107
|
0
|
|
|
|
|
|
my $indices = [@_]; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
110
|
|
|
|
|
|
|
_parent => $self, |
|
111
|
|
|
|
|
|
|
_type => $self->_termType->index_status, |
|
112
|
|
|
|
|
|
|
args => $indices, |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return $q; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub index_wait { |
|
119
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
120
|
0
|
|
|
|
|
|
my $indices = [@_]; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
123
|
|
|
|
|
|
|
_parent => $self, |
|
124
|
|
|
|
|
|
|
_type => $self->_termType->index_wait, |
|
125
|
|
|
|
|
|
|
args => $indices, |
|
126
|
|
|
|
|
|
|
); |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return $q; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub changes { |
|
132
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
135
|
|
|
|
|
|
|
_parent => $self, |
|
136
|
|
|
|
|
|
|
_type => $self->_termType->changes, |
|
137
|
|
|
|
|
|
|
); |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $q; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub insert { |
|
143
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
144
|
0
|
|
|
|
|
|
my $args = shift; |
|
145
|
0
|
|
|
|
|
|
my $params = shift; |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
148
|
|
|
|
|
|
|
_parent => $self, |
|
149
|
|
|
|
|
|
|
_type => $self->_termType->insert, |
|
150
|
|
|
|
|
|
|
args => Rethinkdb::Util->_expr_json($args), |
|
151
|
|
|
|
|
|
|
optargs => $params, |
|
152
|
|
|
|
|
|
|
); |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return $q; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub sync { |
|
158
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
161
|
|
|
|
|
|
|
_parent => $self, |
|
162
|
|
|
|
|
|
|
_type => $self->_termType->sync, |
|
163
|
|
|
|
|
|
|
); |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
return $q; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# get a document by primary key |
|
169
|
|
|
|
|
|
|
# TODO: key can be other things besides string |
|
170
|
|
|
|
|
|
|
sub get { |
|
171
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
172
|
0
|
|
|
|
|
|
my ($key) = @_; |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
175
|
|
|
|
|
|
|
_parent => $self, |
|
176
|
|
|
|
|
|
|
_type => $self->_termType->get, |
|
177
|
|
|
|
|
|
|
args => $key, |
|
178
|
|
|
|
|
|
|
); |
|
179
|
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $q; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Get all documents where the given value matches the value of the requested index |
|
184
|
|
|
|
|
|
|
sub get_all { |
|
185
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# extract values |
|
188
|
0
|
|
|
|
|
|
my $values = \@_; |
|
189
|
0
|
|
|
|
|
|
my $params = {}; |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
0
|
|
|
|
|
if ( ref $values->[0] eq 'ARRAY' ) { |
|
192
|
0
|
|
|
|
|
|
( $values, $params ) = @{$values}; |
|
|
0
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
0
|
|
|
|
|
if ( ref $values->[ $#{$values} ] eq 'HASH' ) { |
|
|
0
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
$params = pop @{$values}; |
|
|
0
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
if ( !$params->{index} ) { |
|
200
|
0
|
|
|
|
|
|
$params->{index} = 'id'; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
204
|
|
|
|
|
|
|
_parent => $self, |
|
205
|
|
|
|
|
|
|
_type => $self->_termType->get_all, |
|
206
|
|
|
|
|
|
|
args => $values, |
|
207
|
|
|
|
|
|
|
optargs => $params, |
|
208
|
|
|
|
|
|
|
); |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
return $q; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub between { |
|
214
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
215
|
0
|
|
|
|
|
|
my ( $lower, $upper, $index, $left_bound, $right_bound ) = @_; |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
my $optargs = {}; |
|
218
|
0
|
0
|
|
|
|
|
if ( ref $index ) { |
|
219
|
0
|
|
|
|
|
|
$optargs = $index; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
else { |
|
222
|
0
|
|
0
|
|
|
|
$optargs->{index} = $index || 'id'; |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
0
|
|
|
|
|
if ($left_bound) { |
|
225
|
0
|
|
|
|
|
|
$optargs->{left_bound} = $left_bound; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
0
|
|
|
|
|
if ($right_bound) { |
|
229
|
0
|
|
|
|
|
|
$optargs->{right_bound} = $right_bound; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
234
|
|
|
|
|
|
|
_parent => $self, |
|
235
|
|
|
|
|
|
|
_type => $self->_termType->between, |
|
236
|
|
|
|
|
|
|
args => [ $lower, $upper ], |
|
237
|
|
|
|
|
|
|
optargs => $optargs, |
|
238
|
|
|
|
|
|
|
); |
|
239
|
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
return $q; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub get_intersecting { |
|
244
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
245
|
0
|
|
|
|
|
|
my $args = shift; |
|
246
|
0
|
|
|
|
|
|
my $optargs = shift; |
|
247
|
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
249
|
|
|
|
|
|
|
_parent => $self, |
|
250
|
|
|
|
|
|
|
_type => $self->_termType->get_intersecting, |
|
251
|
|
|
|
|
|
|
args => $args, |
|
252
|
|
|
|
|
|
|
optargs => $optargs, |
|
253
|
|
|
|
|
|
|
); |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
|
return $q; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
sub get_nearest { |
|
259
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
260
|
0
|
|
|
|
|
|
my $args = shift; |
|
261
|
0
|
|
|
|
|
|
my $optargs = shift; |
|
262
|
|
|
|
|
|
|
|
|
263
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
264
|
|
|
|
|
|
|
_parent => $self, |
|
265
|
|
|
|
|
|
|
_type => $self->_termType->get_nearest, |
|
266
|
|
|
|
|
|
|
args => $args, |
|
267
|
|
|
|
|
|
|
optargs => $optargs, |
|
268
|
|
|
|
|
|
|
); |
|
269
|
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
|
return $q; |
|
271
|
|
|
|
|
|
|
} |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub config { |
|
274
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
275
|
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
277
|
|
|
|
|
|
|
_parent => $self, |
|
278
|
|
|
|
|
|
|
_type => $self->_termType->config, |
|
279
|
|
|
|
|
|
|
); |
|
280
|
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
return $q; |
|
282
|
|
|
|
|
|
|
} |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub rebalance { |
|
285
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
286
|
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
288
|
|
|
|
|
|
|
_parent => $self, |
|
289
|
|
|
|
|
|
|
_type => $self->_termType->rebalance, |
|
290
|
|
|
|
|
|
|
); |
|
291
|
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
|
return $q; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub reconfigure { |
|
296
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
297
|
0
|
|
|
|
|
|
my $args = shift; |
|
298
|
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
300
|
|
|
|
|
|
|
_parent => $self, |
|
301
|
|
|
|
|
|
|
_type => $self->_termType->reconfigure, |
|
302
|
|
|
|
|
|
|
optargs => $args |
|
303
|
|
|
|
|
|
|
); |
|
304
|
|
|
|
|
|
|
|
|
305
|
0
|
|
|
|
|
|
return $q; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub status { |
|
309
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
310
|
|
|
|
|
|
|
|
|
311
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
312
|
|
|
|
|
|
|
_parent => $self, |
|
313
|
|
|
|
|
|
|
_type => $self->_termType->status, |
|
314
|
|
|
|
|
|
|
); |
|
315
|
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
|
return $q; |
|
317
|
|
|
|
|
|
|
} |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub wait { |
|
320
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
321
|
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
|
323
|
|
|
|
|
|
|
_parent => $self, |
|
324
|
|
|
|
|
|
|
_type => $self->_termType->wait, |
|
325
|
|
|
|
|
|
|
); |
|
326
|
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
return $q; |
|
328
|
|
|
|
|
|
|
} |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
1; |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=encoding utf8 |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=head1 NAME |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
Rethinkdb::Query::Table - RethinkDB Query Table |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
L is a type of query that represents a table in a |
|
343
|
|
|
|
|
|
|
database. This classes contains methods to interact with said table. |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
L implements the following attributes. |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=head2 name |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
my $table = r->db('comics')->table('superheros'); |
|
352
|
|
|
|
|
|
|
say $table->name; |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
The name of the table. |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=head1 METHODS |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
L implements the following methods. |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=head2 create |
|
361
|
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
r->db('test')->table('dc_universe')->create->run; |
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
Create this table. A RethinkDB table is a collection of JSON documents. |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
If successful, the operation returns an object: C<< {created => 1} >>. If a |
|
367
|
|
|
|
|
|
|
table with the same name already exists, the operation returns a |
|
368
|
|
|
|
|
|
|
C. |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
B that you can only use alphanumeric characters and underscores for the |
|
371
|
|
|
|
|
|
|
table name. |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=head2 drop |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
r->db('test')->table('dc_universe')->drop->run(conn) |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
Drop this table. The table and all its data will be deleted. |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
If successful, the operation returns an object: C<< {dropped => 1} >>. If the |
|
380
|
|
|
|
|
|
|
specified table doesn't exist a C is returned. |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=head2 index_create |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
r->table('comments')->index_create('post_id')->run; |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
Create a new secondary index on a table. |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=head2 index_drop |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
r->table('dc')->index_drop('code_name')->run; |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
Delete a previously created secondary index of this table. |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head2 index_list |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
r->table('marvel')->index_list->run; |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
List all the secondary indexes of this table. |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=head2 index_rename |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
r->table('marvel')->index_rename('heroId', 'awesomeId')->run; |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
Rename an existing secondary index on a table. If the optional argument |
|
405
|
|
|
|
|
|
|
C is specified as C, a previously existing index with the new |
|
406
|
|
|
|
|
|
|
name will be deleted and the index will be renamed. If C is C |
|
407
|
|
|
|
|
|
|
(the default) an error will be raised if the new index name already exists. |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
=head2 index_status |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
r->table('test')->index_status->run; |
|
412
|
|
|
|
|
|
|
r->table('test')->index_status('timestamp')->run; |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
Get the status of the specified indexes on this table, or the status of all |
|
415
|
|
|
|
|
|
|
indexes on this table if no indexes are specified. |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=head2 index_wait |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
r->table('test')->index_wait->run; |
|
420
|
|
|
|
|
|
|
r->table('test')->index_wait('timestamp')->run; |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
Wait for the specified indexes on this table to be ready, or for all indexes on |
|
423
|
|
|
|
|
|
|
this table to be ready if no indexes are specified. |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=head2 changes |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
my $stream = r->table('games')->changes(sub { |
|
428
|
|
|
|
|
|
|
my $item; |
|
429
|
|
|
|
|
|
|
say Dumper $_; |
|
430
|
|
|
|
|
|
|
})->run; |
|
431
|
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
Return an infinite stream of objects representing changes to a table. Whenever |
|
433
|
|
|
|
|
|
|
an C, C, C or C is performed on the table, an |
|
434
|
|
|
|
|
|
|
object of the form C<< {'old_val' => ..., 'new_val' => ...} >> will be appended |
|
435
|
|
|
|
|
|
|
to the stream. For an C, C will be C, and for a |
|
436
|
|
|
|
|
|
|
C, C will be C. |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=head2 insert |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
r->table('posts')->insert({ |
|
441
|
|
|
|
|
|
|
id => 1, |
|
442
|
|
|
|
|
|
|
title => 'Lorem ipsum', |
|
443
|
|
|
|
|
|
|
content => 'Dolor sit amet' |
|
444
|
|
|
|
|
|
|
})->run; |
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
Insert documents into a table. Accepts a single document or an array of |
|
447
|
|
|
|
|
|
|
documents. |
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=head2 sync |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
L ensures that writes on a given table are written to permanent storage. |
|
452
|
|
|
|
|
|
|
Queries that specify soft durability C<< {durability => 'soft'} >> do not give |
|
453
|
|
|
|
|
|
|
such guarantees, so sync can be used to ensure the state of these queries. A |
|
454
|
|
|
|
|
|
|
call to sync does not return until all previous writes to the table are |
|
455
|
|
|
|
|
|
|
persisted. |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=head2 get |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
r->table('posts')->get('a9849eef-7176-4411-935b-79a6e3c56a74')->run; |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
Get a document by primary key. |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
If no document exists with that primary key, L will return C. |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=head2 get_all |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
r->table('marvel')->get_all('man_of_steel', { index => 'code_name' })->run; |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Get all documents where the given value matches the value of the requested |
|
470
|
|
|
|
|
|
|
index. |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=head2 between |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
r->table('marvel')->between(10, 20)->run; |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
Get all documents between two keys. Accepts three optional arguments: C, |
|
477
|
|
|
|
|
|
|
C, and C. If C is set to the name of a |
|
478
|
|
|
|
|
|
|
secondary index, L will return all documents where that index's value |
|
479
|
|
|
|
|
|
|
is in the specified range (it uses the primary key by default). C |
|
480
|
|
|
|
|
|
|
or C may be set to open or closed to indicate whether or not to |
|
481
|
|
|
|
|
|
|
include that endpoint of the range (by default, C is closed and |
|
482
|
|
|
|
|
|
|
C is open). |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=head2 get_intersecting |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
r->table('geo') |
|
487
|
|
|
|
|
|
|
->get_intersecting( |
|
488
|
|
|
|
|
|
|
r->circle( [ -122.423246, 37.770378359 ], 10, { unit => 'mi' } ), |
|
489
|
|
|
|
|
|
|
{ index => 'location' } )->run; |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
Get all documents where the given geometry object intersects the geometry |
|
492
|
|
|
|
|
|
|
object of the requested geospatial index. |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=head2 get_nearest |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
r->table('geo')->get_nearest( |
|
497
|
|
|
|
|
|
|
r->point( -122.422876, 37.777128 ), |
|
498
|
|
|
|
|
|
|
{ index => 'location', max_dist => 5000 } |
|
499
|
|
|
|
|
|
|
)->run; |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
Get all documents where the specified geospatial index is within a certain |
|
502
|
|
|
|
|
|
|
distance of the specified point (default 100 kilometers). |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=head2 config |
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
r->table('marvel')->config->run; |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
Query (read and/or update) the configurations for individual tables. |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=head2 rebalance |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
r->table('marvel')->rebalance->run; |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Rebalances the shards of a table. |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=head2 reconfigure |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
r->table('marvel')->reconfigure({ shards => 2, replicas => 1 })->run; |
|
519
|
|
|
|
|
|
|
r->table('marvel')->reconfigure( |
|
520
|
|
|
|
|
|
|
{ |
|
521
|
|
|
|
|
|
|
shards => 2, |
|
522
|
|
|
|
|
|
|
replicas => { wooster => 1, wayne => 1 }, |
|
523
|
|
|
|
|
|
|
primary_replica_tag => 'wooster' |
|
524
|
|
|
|
|
|
|
} |
|
525
|
|
|
|
|
|
|
)->run; |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
Reconfigure a table's sharding and replication. |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=head2 status |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
r->table('marvel')->status->run; |
|
532
|
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
Return the status of a table. The return value is an object providing |
|
534
|
|
|
|
|
|
|
information about the table's shards, replicas and replica readiness states |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head2 wait |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
r->table('marvel')->wait->run; |
|
539
|
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
Wait for a table to be ready. A table may be temporarily unavailable |
|
541
|
|
|
|
|
|
|
after creation, rebalancing or reconfiguring. The L command |
|
542
|
|
|
|
|
|
|
blocks until the given table is fully up to date. |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=cut |