line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rethinkdb::Query; |
2
|
15
|
|
|
15
|
|
60
|
use Rethinkdb::Base -base; |
|
15
|
|
|
|
|
17
|
|
|
15
|
|
|
|
|
117
|
|
3
|
|
|
|
|
|
|
|
4
|
15
|
|
|
15
|
|
63
|
use Carp 'croak'; |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
609
|
|
5
|
15
|
|
|
15
|
|
57
|
use Scalar::Util 'weaken'; |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
563
|
|
6
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
55
|
use Rethinkdb; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
116
|
|
8
|
15
|
|
|
15
|
|
58
|
use Rethinkdb::Protocol; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
71
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has [qw{ _rdb _parent _type args optargs }]; |
11
|
|
|
|
|
|
|
has '_termType' => sub { Rethinkdb::Protocol->new->term->termType; }; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
15
|
0
|
0
|
0
|
|
|
|
my $self = bless @_ ? @_ > 1 ? {@_} : { %{ $_[0] } } : {}, |
|
0
|
0
|
|
|
|
|
|
16
|
|
|
|
|
|
|
ref $class || $class; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
0
|
|
|
|
if ( $self->_parent && $self->_parent->_rdb ) { |
19
|
0
|
|
|
|
|
|
my $rdb = $self->_parent->_rdb; |
20
|
0
|
|
|
|
|
|
delete $self->_parent->{_rdb}; |
21
|
0
|
|
|
|
|
|
$self->_rdb($rdb); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# process args and optargs |
25
|
0
|
|
|
|
|
|
$self->_args; |
26
|
0
|
|
|
|
|
|
$self->_optargs; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# ditch parent |
29
|
0
|
|
|
|
|
|
delete $self->{_parent}; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _build { |
35
|
0
|
|
|
0
|
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
my $q = { type => $self->_type }; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if ( $self->args ) { |
39
|
0
|
|
|
|
|
|
foreach ( @{ $self->args } ) { |
|
0
|
|
|
|
|
|
|
40
|
0
|
0
|
0
|
|
|
|
if ( ref $_ && UNIVERSAL::can( $_, 'can' ) && $_->can('_build') ) { |
|
|
|
0
|
|
|
|
|
41
|
0
|
|
|
|
|
|
push @{ $q->{args} }, $_->_build; |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
|
push @{ $q->{args} }, $_; |
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# else { |
50
|
|
|
|
|
|
|
# push @{ $q->{args} }, undef; |
51
|
|
|
|
|
|
|
# } |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if ( $self->optargs ) { |
54
|
0
|
|
|
|
|
|
foreach ( keys %{ $self->optargs } ) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $value = $self->{optargs}->{$_}; |
56
|
0
|
0
|
0
|
|
|
|
if ( ref $value |
|
|
|
0
|
|
|
|
|
57
|
|
|
|
|
|
|
&& UNIVERSAL::can( $value, 'can' ) |
58
|
|
|
|
|
|
|
&& $value->can('_build') ) |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
|
|
|
push @{ $q->{optargs} }, { key => $_, val => $value->_build }; |
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
0
|
|
|
|
|
|
push @{ $q->{optargs} }, { key => $_, val => $value }; |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $q; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _args { |
72
|
0
|
|
|
0
|
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my $args = $self->args; |
74
|
0
|
|
|
|
|
|
my $parent = $self->_parent; |
75
|
0
|
|
|
|
|
|
delete $self->{args}; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if ( defined $args ) { |
|
|
0
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if ( ref $args ne 'ARRAY' ) { |
80
|
0
|
|
|
|
|
|
$args = [$args]; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $expr_args = []; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if ($parent) { |
86
|
0
|
|
|
|
|
|
push @{$expr_args}, $parent; |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
foreach ( @{$args} ) { |
|
0
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
push @{$expr_args}, Rethinkdb::Util->_expr($_); |
|
0
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$self->args($expr_args); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( defined $parent ) { |
96
|
0
|
|
|
|
|
|
$self->args( [$parent] ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _optargs { |
103
|
0
|
|
|
0
|
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
my $optargs = $self->optargs; |
105
|
0
|
|
|
|
|
|
delete $self->{optargs}; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
if ($optargs) { |
108
|
0
|
0
|
|
|
|
|
if ( ref $optargs ) { |
109
|
0
|
|
|
|
|
|
my $expr_optargs = {}; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
foreach ( keys %{$optargs} ) { |
|
0
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
$expr_optargs->{$_} = Rethinkdb::Util->_expr( $optargs->{$_} ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->optargs($expr_optargs); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
return; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub run { |
123
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
124
|
0
|
|
|
|
|
|
my ( $connection, $args, $callback ) = @_; |
125
|
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
if ( ref $connection ne 'Rethinkdb::IO' ) { |
127
|
0
|
|
|
|
|
|
$callback = $args; |
128
|
0
|
|
|
|
|
|
$args = $connection; |
129
|
0
|
0
|
0
|
|
|
|
if ( $self->_rdb && $self->_rdb->io ) { |
130
|
0
|
|
|
|
|
|
$connection = $self->_rdb->io; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
else { |
133
|
0
|
|
|
|
|
|
croak 'ERROR: run() was not given a connection'; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if ( ref $args eq 'CODE' ) { |
138
|
0
|
|
|
|
|
|
$callback = $args; |
139
|
0
|
|
|
|
|
|
$args = {}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
return $connection->_start( $self, $args, $callback ); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# WRITING DATA |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub update { |
148
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
149
|
0
|
|
|
|
|
|
my $args = shift; |
150
|
0
|
0
|
|
|
|
|
my $optargs = @_ ? @_ > 1 ? {@_} : { %{ $_[0] } } : {}; |
|
0
|
0
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
153
|
|
|
|
|
|
|
_parent => $self, |
154
|
|
|
|
|
|
|
_type => $self->_termType->update, |
155
|
|
|
|
|
|
|
args => Rethinkdb::Util->_wrap_func( $args, 1 ), |
156
|
|
|
|
|
|
|
optargs => $optargs, |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
return $q; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub replace { |
163
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
164
|
0
|
|
|
|
|
|
my $args = shift; |
165
|
0
|
0
|
|
|
|
|
my $optargs = @_ ? @_ > 1 ? {@_} : { %{ $_[0] } } : {}; |
|
0
|
0
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
168
|
|
|
|
|
|
|
_parent => $self, |
169
|
|
|
|
|
|
|
_type => $self->_termType->replace, |
170
|
|
|
|
|
|
|
args => Rethinkdb::Util->_wrap_func($args), |
171
|
|
|
|
|
|
|
optargs => $optargs, |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $q; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub delete { |
178
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
179
|
0
|
0
|
|
|
|
|
my $optargs = @_ ? @_ > 1 ? {@_} : { %{ $_[0] } } : {}; |
|
0
|
0
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
182
|
|
|
|
|
|
|
_parent => $self, |
183
|
|
|
|
|
|
|
_type => $self->_termType->delete, |
184
|
|
|
|
|
|
|
optargs => $optargs, |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
return $q; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# SELECTING DATA |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub filter { |
193
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
194
|
0
|
|
|
|
|
|
my $args = shift; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
197
|
|
|
|
|
|
|
_parent => $self, |
198
|
|
|
|
|
|
|
_type => $self->_termType->filter, |
199
|
|
|
|
|
|
|
args => Rethinkdb::Util->_wrap_func($args), |
200
|
|
|
|
|
|
|
); |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
return $q; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# JOINS |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub inner_join { |
208
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
209
|
0
|
|
|
|
|
|
my ( $table, $predicate ) = @_; |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
212
|
|
|
|
|
|
|
_parent => $self, |
213
|
|
|
|
|
|
|
_type => $self->_termType->inner_join, |
214
|
|
|
|
|
|
|
args => [ $table, $predicate ], |
215
|
|
|
|
|
|
|
); |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
return $q; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub outer_join { |
221
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
222
|
0
|
|
|
|
|
|
my ( $table, $predicate ) = @_; |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
225
|
|
|
|
|
|
|
_parent => $self, |
226
|
|
|
|
|
|
|
_type => $self->_termType->outer_join, |
227
|
|
|
|
|
|
|
args => [ $table, $predicate ], |
228
|
|
|
|
|
|
|
); |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
return $q; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub eq_join { |
234
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
235
|
0
|
|
|
|
|
|
my ( $left, $table, $optargs ) = @_; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
238
|
|
|
|
|
|
|
_parent => $self, |
239
|
|
|
|
|
|
|
_type => $self->_termType->eq_join, |
240
|
|
|
|
|
|
|
args => [ $left, $table ], |
241
|
|
|
|
|
|
|
optargs => $optargs, |
242
|
|
|
|
|
|
|
); |
243
|
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
|
return $q; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub zip { |
248
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
my $q |
251
|
|
|
|
|
|
|
= Rethinkdb::Query->new( _parent => $self, _type => $self->_termType->zip, |
252
|
|
|
|
|
|
|
); |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
return $q; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# TRANSFORMATIONS |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub map { |
260
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
261
|
0
|
|
|
|
|
|
my ($args) = @_; |
262
|
|
|
|
|
|
|
|
263
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
264
|
|
|
|
|
|
|
_parent => $self, |
265
|
|
|
|
|
|
|
_type => $self->_termType->map, |
266
|
|
|
|
|
|
|
args => Rethinkdb::Util->_wrap_func($args), |
267
|
|
|
|
|
|
|
); |
268
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
|
return $q; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub with_fields { |
273
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
274
|
0
|
|
|
|
|
|
my $args = [@_]; |
275
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
277
|
|
|
|
|
|
|
_parent => $self, |
278
|
|
|
|
|
|
|
_type => $self->_termType->with_fields, |
279
|
|
|
|
|
|
|
args => $args, |
280
|
|
|
|
|
|
|
); |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
return $q; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub concat_map { |
286
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
287
|
0
|
|
|
|
|
|
my $args = [@_]; |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
290
|
|
|
|
|
|
|
_parent => $self, |
291
|
|
|
|
|
|
|
_type => $self->_termType->concat_map, |
292
|
|
|
|
|
|
|
args => $args, |
293
|
|
|
|
|
|
|
); |
294
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
return $q; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub order_by { |
299
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
300
|
0
|
|
|
|
|
|
my $args = [@_]; |
301
|
|
|
|
|
|
|
|
302
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
303
|
|
|
|
|
|
|
_parent => $self, |
304
|
|
|
|
|
|
|
_type => $self->_termType->order_by, |
305
|
|
|
|
|
|
|
args => $args, |
306
|
|
|
|
|
|
|
); |
307
|
|
|
|
|
|
|
|
308
|
0
|
|
|
|
|
|
return $q; |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub skip { |
312
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
313
|
0
|
|
|
|
|
|
my $number = shift; |
314
|
|
|
|
|
|
|
|
315
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
316
|
|
|
|
|
|
|
_parent => $self, |
317
|
|
|
|
|
|
|
_type => $self->_termType->skip, |
318
|
|
|
|
|
|
|
args => $number, |
319
|
|
|
|
|
|
|
); |
320
|
|
|
|
|
|
|
|
321
|
0
|
|
|
|
|
|
return $q; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub limit { |
325
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
326
|
0
|
|
|
|
|
|
my $number = shift; |
327
|
|
|
|
|
|
|
|
328
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
329
|
|
|
|
|
|
|
_parent => $self, |
330
|
|
|
|
|
|
|
_type => $self->_termType->limit, |
331
|
|
|
|
|
|
|
args => $number, |
332
|
|
|
|
|
|
|
); |
333
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
return $q; |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub slice { |
338
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
339
|
0
|
|
|
|
|
|
my $args = [@_]; |
340
|
|
|
|
|
|
|
|
341
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
342
|
|
|
|
|
|
|
_parent => $self, |
343
|
|
|
|
|
|
|
_type => $self->_termType->slice, |
344
|
|
|
|
|
|
|
args => $args, |
345
|
|
|
|
|
|
|
); |
346
|
|
|
|
|
|
|
|
347
|
0
|
|
|
|
|
|
return $q; |
348
|
|
|
|
|
|
|
} |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
sub nth { |
351
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
352
|
0
|
|
|
|
|
|
my $number = [@_]; |
353
|
|
|
|
|
|
|
|
354
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
355
|
|
|
|
|
|
|
_parent => $self, |
356
|
|
|
|
|
|
|
_type => $self->_termType->nth, |
357
|
|
|
|
|
|
|
args => $number, |
358
|
|
|
|
|
|
|
); |
359
|
|
|
|
|
|
|
|
360
|
0
|
|
|
|
|
|
return $q; |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub offsets_of { |
364
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
365
|
0
|
|
|
|
|
|
my ($args) = @_; |
366
|
|
|
|
|
|
|
|
367
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
368
|
|
|
|
|
|
|
_parent => $self, |
369
|
|
|
|
|
|
|
_type => $self->_termType->offsets_of, |
370
|
|
|
|
|
|
|
args => Rethinkdb::Util->_wrap_func($args), |
371
|
|
|
|
|
|
|
); |
372
|
|
|
|
|
|
|
|
373
|
0
|
|
|
|
|
|
return $q; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
sub is_empty { |
377
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
380
|
|
|
|
|
|
|
_parent => $self, |
381
|
|
|
|
|
|
|
_type => $self->_termType->is_empty, |
382
|
|
|
|
|
|
|
); |
383
|
|
|
|
|
|
|
|
384
|
0
|
|
|
|
|
|
return $q; |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
sub union { |
388
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
389
|
0
|
|
|
|
|
|
my $args = shift; |
390
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
392
|
|
|
|
|
|
|
_parent => $self, |
393
|
|
|
|
|
|
|
_type => $self->_termType->union, |
394
|
|
|
|
|
|
|
args => $args, |
395
|
|
|
|
|
|
|
); |
396
|
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
|
return $q; |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
sub sample { |
401
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
402
|
0
|
|
|
|
|
|
my $args = shift; |
403
|
|
|
|
|
|
|
|
404
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
405
|
|
|
|
|
|
|
_parent => $self, |
406
|
|
|
|
|
|
|
_type => $self->_termType->sample, |
407
|
|
|
|
|
|
|
args => $args, |
408
|
|
|
|
|
|
|
); |
409
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
|
return $q; |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
# AGGREGATION |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
sub group { |
416
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
417
|
0
|
|
|
|
|
|
my $args = [@_]; |
418
|
0
|
|
|
|
|
|
my $optargs = {}; |
419
|
|
|
|
|
|
|
|
420
|
0
|
0
|
|
|
|
|
if ( ref $args->[ $#{$args} ] eq 'HASH' ) { |
|
0
|
|
|
|
|
|
|
421
|
0
|
|
|
|
|
|
$optargs = pop @{$args}; |
|
0
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
} |
423
|
|
|
|
|
|
|
|
424
|
0
|
0
|
0
|
|
|
|
if ( ref $args->[0] && ref $args->[0] ne 'CODE' ) { |
425
|
0
|
|
|
|
|
|
$args = Rethinkdb::Util->_wrap_func( $args->[0] ); |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
|
428
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
429
|
|
|
|
|
|
|
_parent => $self, |
430
|
|
|
|
|
|
|
_type => $self->_termType->group, |
431
|
|
|
|
|
|
|
args => $args, |
432
|
|
|
|
|
|
|
optargs => $optargs |
433
|
|
|
|
|
|
|
); |
434
|
|
|
|
|
|
|
|
435
|
0
|
|
|
|
|
|
return $q; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
sub ungroup { |
439
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
440
|
|
|
|
|
|
|
|
441
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
442
|
|
|
|
|
|
|
_parent => $self, |
443
|
|
|
|
|
|
|
_type => $self->_termType->ungroup, |
444
|
|
|
|
|
|
|
); |
445
|
|
|
|
|
|
|
|
446
|
0
|
|
|
|
|
|
return $q; |
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
sub reduce { |
450
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
451
|
0
|
|
|
|
|
|
my $function = shift; |
452
|
|
|
|
|
|
|
|
453
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
454
|
|
|
|
|
|
|
_parent => $self, |
455
|
|
|
|
|
|
|
_type => $self->_termType->reduce, |
456
|
|
|
|
|
|
|
args => $function, |
457
|
|
|
|
|
|
|
); |
458
|
|
|
|
|
|
|
|
459
|
0
|
|
|
|
|
|
return $q; |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
sub fold { |
463
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
464
|
0
|
|
|
|
|
|
my $acc = shift; |
465
|
0
|
|
|
|
|
|
my $fn = shift; |
466
|
0
|
|
|
|
|
|
my $emitter = shift; |
467
|
|
|
|
|
|
|
|
468
|
0
|
|
|
|
|
|
my $args = [$acc, $fn]; |
469
|
0
|
|
|
|
|
|
my $optargs = {}; |
470
|
|
|
|
|
|
|
|
471
|
0
|
0
|
|
|
|
|
if($emitter) { |
472
|
0
|
|
|
|
|
|
$optargs = { emit => $emitter }; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
476
|
|
|
|
|
|
|
_parent => $self, |
477
|
|
|
|
|
|
|
_type => $self->_termType->fold, |
478
|
|
|
|
|
|
|
args => $args, |
479
|
|
|
|
|
|
|
optargs => $optargs |
480
|
|
|
|
|
|
|
); |
481
|
|
|
|
|
|
|
|
482
|
0
|
|
|
|
|
|
return $q; |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
sub count { |
486
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
487
|
0
|
|
|
|
|
|
my $args = shift; |
488
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
490
|
|
|
|
|
|
|
_parent => $self, |
491
|
|
|
|
|
|
|
_type => $self->_termType->count, |
492
|
|
|
|
|
|
|
args => $args |
493
|
|
|
|
|
|
|
); |
494
|
|
|
|
|
|
|
|
495
|
0
|
|
|
|
|
|
return $q; |
496
|
|
|
|
|
|
|
} |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
sub sum { |
499
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
500
|
0
|
|
|
|
|
|
my $args = [@_]; |
501
|
|
|
|
|
|
|
|
502
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
503
|
|
|
|
|
|
|
_parent => $self, |
504
|
|
|
|
|
|
|
_type => $self->_termType->sum, |
505
|
|
|
|
|
|
|
args => $args |
506
|
|
|
|
|
|
|
); |
507
|
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
|
return $q; |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
sub avg { |
512
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
513
|
0
|
|
|
|
|
|
my $args = [@_]; |
514
|
|
|
|
|
|
|
|
515
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
516
|
|
|
|
|
|
|
_parent => $self, |
517
|
|
|
|
|
|
|
_type => $self->_termType->avg, |
518
|
|
|
|
|
|
|
args => $args |
519
|
|
|
|
|
|
|
); |
520
|
|
|
|
|
|
|
|
521
|
0
|
|
|
|
|
|
return $q; |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
sub min { |
525
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
526
|
0
|
|
|
|
|
|
my $args = [@_]; |
527
|
|
|
|
|
|
|
|
528
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
529
|
|
|
|
|
|
|
_parent => $self, |
530
|
|
|
|
|
|
|
_type => $self->_termType->min, |
531
|
|
|
|
|
|
|
args => $args |
532
|
|
|
|
|
|
|
); |
533
|
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
|
return $q; |
535
|
|
|
|
|
|
|
} |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
sub max { |
538
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
539
|
0
|
|
|
|
|
|
my $args = [@_]; |
540
|
|
|
|
|
|
|
|
541
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
542
|
|
|
|
|
|
|
_parent => $self, |
543
|
|
|
|
|
|
|
_type => $self->_termType->max, |
544
|
|
|
|
|
|
|
args => $args |
545
|
|
|
|
|
|
|
); |
546
|
|
|
|
|
|
|
|
547
|
0
|
|
|
|
|
|
return $q; |
548
|
|
|
|
|
|
|
} |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
sub distinct { |
551
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
552
|
|
|
|
|
|
|
|
553
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
554
|
|
|
|
|
|
|
_parent => $self, |
555
|
|
|
|
|
|
|
_type => $self->_termType->distinct, |
556
|
|
|
|
|
|
|
); |
557
|
|
|
|
|
|
|
|
558
|
0
|
|
|
|
|
|
return $q; |
559
|
|
|
|
|
|
|
} |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
sub contains { |
562
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
563
|
0
|
|
|
|
|
|
my $args = [@_]; |
564
|
|
|
|
|
|
|
|
565
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
566
|
|
|
|
|
|
|
_parent => $self, |
567
|
|
|
|
|
|
|
_type => $self->_termType->contains, |
568
|
|
|
|
|
|
|
args => $args |
569
|
|
|
|
|
|
|
); |
570
|
|
|
|
|
|
|
|
571
|
0
|
|
|
|
|
|
return $q; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
# DOCUMENT MANIPULATION |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
sub pluck { |
577
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
578
|
0
|
|
|
|
|
|
my $args = [@_]; |
579
|
|
|
|
|
|
|
|
580
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
581
|
|
|
|
|
|
|
_parent => $self, |
582
|
|
|
|
|
|
|
_type => $self->_termType->pluck, |
583
|
|
|
|
|
|
|
args => $args |
584
|
|
|
|
|
|
|
); |
585
|
|
|
|
|
|
|
|
586
|
0
|
|
|
|
|
|
return $q; |
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
sub without { |
590
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
591
|
0
|
|
|
|
|
|
my $args = [@_]; |
592
|
|
|
|
|
|
|
|
593
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
594
|
|
|
|
|
|
|
_parent => $self, |
595
|
|
|
|
|
|
|
_type => $self->_termType->without, |
596
|
|
|
|
|
|
|
args => $args |
597
|
|
|
|
|
|
|
); |
598
|
|
|
|
|
|
|
|
599
|
0
|
|
|
|
|
|
return $q; |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
sub merge { |
603
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
604
|
0
|
|
|
|
|
|
my $args = shift; |
605
|
|
|
|
|
|
|
|
606
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
607
|
|
|
|
|
|
|
_parent => $self, |
608
|
|
|
|
|
|
|
_type => $self->_termType->merge, |
609
|
|
|
|
|
|
|
args => $args |
610
|
|
|
|
|
|
|
); |
611
|
|
|
|
|
|
|
|
612
|
0
|
|
|
|
|
|
return $q; |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
sub append { |
616
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
# my $args = @_ ? @_ > 1 ? [@_] : [ @{ $_[0] } ] : []; |
619
|
0
|
|
|
|
|
|
my $args = shift; |
620
|
|
|
|
|
|
|
|
621
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
622
|
|
|
|
|
|
|
_parent => $self, |
623
|
|
|
|
|
|
|
_type => $self->_termType->append, |
624
|
|
|
|
|
|
|
args => $args |
625
|
|
|
|
|
|
|
); |
626
|
|
|
|
|
|
|
|
627
|
0
|
|
|
|
|
|
return $q; |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
sub prepend { |
631
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
# my $args = @_ ? @_ > 1 ? [@_] : [ @{ $_[0] } ] : []; |
634
|
0
|
|
|
|
|
|
my $args = shift; |
635
|
|
|
|
|
|
|
|
636
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
637
|
|
|
|
|
|
|
_parent => $self, |
638
|
|
|
|
|
|
|
_type => $self->_termType->prepend, |
639
|
|
|
|
|
|
|
args => $args |
640
|
|
|
|
|
|
|
); |
641
|
|
|
|
|
|
|
|
642
|
0
|
|
|
|
|
|
return $q; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
sub difference { |
646
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
647
|
0
|
|
|
|
|
|
my $args = shift; |
648
|
|
|
|
|
|
|
|
649
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
650
|
|
|
|
|
|
|
_parent => $self, |
651
|
|
|
|
|
|
|
_type => $self->_termType->difference, |
652
|
|
|
|
|
|
|
args => [$args], |
653
|
|
|
|
|
|
|
); |
654
|
|
|
|
|
|
|
|
655
|
0
|
|
|
|
|
|
return $q; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
sub set_insert { |
659
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
660
|
0
|
|
|
|
|
|
my $args = shift; |
661
|
|
|
|
|
|
|
|
662
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
663
|
|
|
|
|
|
|
_parent => $self, |
664
|
|
|
|
|
|
|
_type => $self->_termType->set_insert, |
665
|
|
|
|
|
|
|
args => $args, |
666
|
|
|
|
|
|
|
); |
667
|
|
|
|
|
|
|
|
668
|
0
|
|
|
|
|
|
return $q; |
669
|
|
|
|
|
|
|
} |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
sub set_union { |
672
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
673
|
0
|
|
|
|
|
|
my $args = shift; |
674
|
|
|
|
|
|
|
|
675
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
676
|
|
|
|
|
|
|
_parent => $self, |
677
|
|
|
|
|
|
|
_type => $self->_termType->set_union, |
678
|
|
|
|
|
|
|
args => [$args], |
679
|
|
|
|
|
|
|
); |
680
|
|
|
|
|
|
|
|
681
|
0
|
|
|
|
|
|
return $q; |
682
|
|
|
|
|
|
|
} |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
sub set_intersection { |
685
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
686
|
0
|
|
|
|
|
|
my $args = shift; |
687
|
|
|
|
|
|
|
|
688
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
689
|
|
|
|
|
|
|
_parent => $self, |
690
|
|
|
|
|
|
|
_type => $self->_termType->set_intersection, |
691
|
|
|
|
|
|
|
args => [$args], |
692
|
|
|
|
|
|
|
); |
693
|
|
|
|
|
|
|
|
694
|
0
|
|
|
|
|
|
return $q; |
695
|
|
|
|
|
|
|
} |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
sub set_difference { |
698
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
699
|
0
|
|
|
|
|
|
my $args = shift; |
700
|
|
|
|
|
|
|
|
701
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
702
|
|
|
|
|
|
|
_parent => $self, |
703
|
|
|
|
|
|
|
_type => $self->_termType->set_difference, |
704
|
|
|
|
|
|
|
args => [$args], |
705
|
|
|
|
|
|
|
); |
706
|
|
|
|
|
|
|
|
707
|
0
|
|
|
|
|
|
return $q; |
708
|
|
|
|
|
|
|
} |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
sub get_field { |
711
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
712
|
0
|
|
|
|
|
|
my $args = shift; |
713
|
|
|
|
|
|
|
|
714
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
715
|
|
|
|
|
|
|
_parent => $self, |
716
|
|
|
|
|
|
|
_type => $self->_termType->get_field, |
717
|
|
|
|
|
|
|
args => $args |
718
|
|
|
|
|
|
|
); |
719
|
|
|
|
|
|
|
|
720
|
0
|
|
|
|
|
|
return $q; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
# TODO: replace this with AUTOLOAD or overload %{} |
724
|
|
|
|
|
|
|
# to get something like r->table->get()->{attr}->run; |
725
|
|
|
|
|
|
|
# or like r->table->get()->attr->run; |
726
|
|
|
|
|
|
|
sub bracket { |
727
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
728
|
0
|
|
|
|
|
|
my $args = shift; |
729
|
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
731
|
|
|
|
|
|
|
_parent => $self, |
732
|
|
|
|
|
|
|
_type => $self->_termType->bracket, |
733
|
|
|
|
|
|
|
args => $args |
734
|
|
|
|
|
|
|
); |
735
|
|
|
|
|
|
|
|
736
|
0
|
|
|
|
|
|
return $q; |
737
|
|
|
|
|
|
|
} |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
# for backwards compatibility |
740
|
0
|
|
|
0
|
1
|
|
sub attr { bracket(@_) } |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
sub has_fields { |
743
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
744
|
0
|
|
|
|
|
|
my $args = shift; |
745
|
|
|
|
|
|
|
|
746
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
747
|
|
|
|
|
|
|
_parent => $self, |
748
|
|
|
|
|
|
|
_type => $self->_termType->has_fields, |
749
|
|
|
|
|
|
|
args => $args |
750
|
|
|
|
|
|
|
); |
751
|
|
|
|
|
|
|
|
752
|
0
|
|
|
|
|
|
return $q; |
753
|
|
|
|
|
|
|
} |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
sub insert_at { |
756
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
757
|
0
|
|
|
|
|
|
my $args = [@_]; |
758
|
|
|
|
|
|
|
|
759
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
760
|
|
|
|
|
|
|
_parent => $self, |
761
|
|
|
|
|
|
|
_type => $self->_termType->insert_at, |
762
|
|
|
|
|
|
|
args => $args, |
763
|
|
|
|
|
|
|
); |
764
|
|
|
|
|
|
|
|
765
|
0
|
|
|
|
|
|
return $q; |
766
|
|
|
|
|
|
|
} |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
sub splice_at { |
769
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
770
|
0
|
|
|
|
|
|
my $args = [@_]; |
771
|
|
|
|
|
|
|
|
772
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
773
|
|
|
|
|
|
|
_parent => $self, |
774
|
|
|
|
|
|
|
_type => $self->_termType->splice_at, |
775
|
|
|
|
|
|
|
args => $args, |
776
|
|
|
|
|
|
|
); |
777
|
|
|
|
|
|
|
|
778
|
0
|
|
|
|
|
|
return $q; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
sub delete_at { |
782
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
783
|
0
|
|
|
|
|
|
my $args = [@_]; |
784
|
|
|
|
|
|
|
|
785
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
786
|
|
|
|
|
|
|
_parent => $self, |
787
|
|
|
|
|
|
|
_type => $self->_termType->delete_at, |
788
|
|
|
|
|
|
|
args => $args, |
789
|
|
|
|
|
|
|
); |
790
|
|
|
|
|
|
|
|
791
|
0
|
|
|
|
|
|
return $q; |
792
|
|
|
|
|
|
|
} |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
sub change_at { |
795
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
796
|
0
|
|
|
|
|
|
my $args = [@_]; |
797
|
|
|
|
|
|
|
|
798
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
799
|
|
|
|
|
|
|
_parent => $self, |
800
|
|
|
|
|
|
|
_type => $self->_termType->change_at, |
801
|
|
|
|
|
|
|
args => $args, |
802
|
|
|
|
|
|
|
); |
803
|
|
|
|
|
|
|
|
804
|
0
|
|
|
|
|
|
return $q; |
805
|
|
|
|
|
|
|
} |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
sub keys { |
808
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
809
|
0
|
|
|
|
|
|
my $args = [@_]; |
810
|
|
|
|
|
|
|
|
811
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
812
|
|
|
|
|
|
|
_parent => $self, |
813
|
|
|
|
|
|
|
_type => $self->_termType->keys, |
814
|
|
|
|
|
|
|
args => $args, |
815
|
|
|
|
|
|
|
); |
816
|
|
|
|
|
|
|
|
817
|
0
|
|
|
|
|
|
return $q; |
818
|
|
|
|
|
|
|
} |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
sub values { |
821
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
822
|
0
|
|
|
|
|
|
my $args = [@_]; |
823
|
|
|
|
|
|
|
|
824
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
825
|
|
|
|
|
|
|
_parent => $self, |
826
|
|
|
|
|
|
|
_type => $self->_termType->values, |
827
|
|
|
|
|
|
|
args => $args, |
828
|
|
|
|
|
|
|
); |
829
|
|
|
|
|
|
|
|
830
|
0
|
|
|
|
|
|
return $q; |
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
# STRING MANIPULATION |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
sub match { |
836
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
837
|
0
|
|
|
|
|
|
my ($expr) = @_; |
838
|
|
|
|
|
|
|
|
839
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
840
|
|
|
|
|
|
|
_parent => $self, |
841
|
|
|
|
|
|
|
_type => $self->_termType->match, |
842
|
|
|
|
|
|
|
args => $expr |
843
|
|
|
|
|
|
|
); |
844
|
|
|
|
|
|
|
|
845
|
0
|
|
|
|
|
|
return $q; |
846
|
|
|
|
|
|
|
} |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
sub split { |
849
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
850
|
0
|
|
|
|
|
|
my ($expr) = @_; |
851
|
|
|
|
|
|
|
|
852
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
853
|
|
|
|
|
|
|
_parent => $self, |
854
|
|
|
|
|
|
|
_type => $self->_termType->split, |
855
|
|
|
|
|
|
|
args => $expr |
856
|
|
|
|
|
|
|
); |
857
|
|
|
|
|
|
|
|
858
|
0
|
|
|
|
|
|
return $q; |
859
|
|
|
|
|
|
|
} |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
sub upcase { |
862
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
863
|
|
|
|
|
|
|
|
864
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
865
|
|
|
|
|
|
|
_parent => $self, |
866
|
|
|
|
|
|
|
_type => $self->_termType->upcase, |
867
|
|
|
|
|
|
|
); |
868
|
|
|
|
|
|
|
|
869
|
0
|
|
|
|
|
|
return $q; |
870
|
|
|
|
|
|
|
} |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
sub downcase { |
873
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
874
|
|
|
|
|
|
|
|
875
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
876
|
|
|
|
|
|
|
_parent => $self, |
877
|
|
|
|
|
|
|
_type => $self->_termType->downcase, |
878
|
|
|
|
|
|
|
); |
879
|
|
|
|
|
|
|
|
880
|
0
|
|
|
|
|
|
return $q; |
881
|
|
|
|
|
|
|
} |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
# MATH AND LOGIC |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
sub add { |
887
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
888
|
0
|
|
|
|
|
|
my ($args) = @_; |
889
|
|
|
|
|
|
|
|
890
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
891
|
|
|
|
|
|
|
_parent => $self, |
892
|
|
|
|
|
|
|
_type => $self->_termType->add, |
893
|
|
|
|
|
|
|
args => [$args], |
894
|
|
|
|
|
|
|
); |
895
|
|
|
|
|
|
|
|
896
|
0
|
|
|
|
|
|
return $q; |
897
|
|
|
|
|
|
|
} |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
sub sub { |
900
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
901
|
0
|
|
|
|
|
|
my ($args) = @_; |
902
|
|
|
|
|
|
|
|
903
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
904
|
|
|
|
|
|
|
_parent => $self, |
905
|
|
|
|
|
|
|
_type => $self->_termType->sub, |
906
|
|
|
|
|
|
|
args => $args, |
907
|
|
|
|
|
|
|
); |
908
|
|
|
|
|
|
|
|
909
|
0
|
|
|
|
|
|
return $q; |
910
|
|
|
|
|
|
|
} |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
sub mul { |
913
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
914
|
0
|
|
|
|
|
|
my ($args) = @_; |
915
|
|
|
|
|
|
|
|
916
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
917
|
|
|
|
|
|
|
_parent => $self, |
918
|
|
|
|
|
|
|
_type => $self->_termType->mul, |
919
|
|
|
|
|
|
|
args => $args, |
920
|
|
|
|
|
|
|
); |
921
|
|
|
|
|
|
|
|
922
|
0
|
|
|
|
|
|
return $q; |
923
|
|
|
|
|
|
|
} |
924
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
sub div { |
926
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
927
|
0
|
|
|
|
|
|
my ($args) = @_; |
928
|
|
|
|
|
|
|
|
929
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
930
|
|
|
|
|
|
|
_parent => $self, |
931
|
|
|
|
|
|
|
_type => $self->_termType->div, |
932
|
|
|
|
|
|
|
args => $args, |
933
|
|
|
|
|
|
|
); |
934
|
|
|
|
|
|
|
|
935
|
0
|
|
|
|
|
|
return $q; |
936
|
|
|
|
|
|
|
} |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
sub mod { |
939
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
940
|
0
|
|
|
|
|
|
my ($args) = @_; |
941
|
|
|
|
|
|
|
|
942
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
943
|
|
|
|
|
|
|
_parent => $self, |
944
|
|
|
|
|
|
|
_type => $self->_termType->mod, |
945
|
|
|
|
|
|
|
args => $args, |
946
|
|
|
|
|
|
|
); |
947
|
|
|
|
|
|
|
|
948
|
0
|
|
|
|
|
|
return $q; |
949
|
|
|
|
|
|
|
} |
950
|
|
|
|
|
|
|
|
951
|
|
|
|
|
|
|
sub and { |
952
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
953
|
0
|
|
|
|
|
|
my ($args) = @_; |
954
|
|
|
|
|
|
|
|
955
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
956
|
|
|
|
|
|
|
_parent => $self, |
957
|
|
|
|
|
|
|
_type => $self->_termType->and, |
958
|
|
|
|
|
|
|
args => $args, |
959
|
|
|
|
|
|
|
); |
960
|
|
|
|
|
|
|
|
961
|
0
|
|
|
|
|
|
return $q; |
962
|
|
|
|
|
|
|
} |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
sub or { |
965
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
966
|
0
|
|
|
|
|
|
my ($args) = @_; |
967
|
|
|
|
|
|
|
|
968
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
969
|
|
|
|
|
|
|
_parent => $self, |
970
|
|
|
|
|
|
|
_type => $self->_termType->or, |
971
|
|
|
|
|
|
|
args => $args, |
972
|
|
|
|
|
|
|
); |
973
|
|
|
|
|
|
|
|
974
|
0
|
|
|
|
|
|
return $q; |
975
|
|
|
|
|
|
|
} |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
sub eq { |
978
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
979
|
0
|
|
|
|
|
|
my ($args) = @_; |
980
|
|
|
|
|
|
|
|
981
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
982
|
|
|
|
|
|
|
_parent => $self, |
983
|
|
|
|
|
|
|
_type => $self->_termType->eq, |
984
|
|
|
|
|
|
|
args => $args, |
985
|
|
|
|
|
|
|
); |
986
|
|
|
|
|
|
|
|
987
|
0
|
|
|
|
|
|
return $q; |
988
|
|
|
|
|
|
|
} |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
sub ne { |
991
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
992
|
0
|
|
|
|
|
|
my ($args) = @_; |
993
|
|
|
|
|
|
|
|
994
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
995
|
|
|
|
|
|
|
_parent => $self, |
996
|
|
|
|
|
|
|
_type => $self->_termType->ne, |
997
|
|
|
|
|
|
|
args => $args, |
998
|
|
|
|
|
|
|
); |
999
|
|
|
|
|
|
|
|
1000
|
0
|
|
|
|
|
|
return $q; |
1001
|
|
|
|
|
|
|
} |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
sub gt { |
1004
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1005
|
0
|
|
|
|
|
|
my ($args) = @_; |
1006
|
|
|
|
|
|
|
|
1007
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1008
|
|
|
|
|
|
|
_parent => $self, |
1009
|
|
|
|
|
|
|
_type => $self->_termType->gt, |
1010
|
|
|
|
|
|
|
args => $args, |
1011
|
|
|
|
|
|
|
); |
1012
|
|
|
|
|
|
|
|
1013
|
0
|
|
|
|
|
|
return $q; |
1014
|
|
|
|
|
|
|
} |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
sub ge { |
1017
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1018
|
0
|
|
|
|
|
|
my ($args) = @_; |
1019
|
|
|
|
|
|
|
|
1020
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1021
|
|
|
|
|
|
|
_parent => $self, |
1022
|
|
|
|
|
|
|
_type => $self->_termType->ge, |
1023
|
|
|
|
|
|
|
args => $args, |
1024
|
|
|
|
|
|
|
); |
1025
|
|
|
|
|
|
|
|
1026
|
0
|
|
|
|
|
|
return $q; |
1027
|
|
|
|
|
|
|
} |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
sub lt { |
1030
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1031
|
0
|
|
|
|
|
|
my ($args) = @_; |
1032
|
|
|
|
|
|
|
|
1033
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1034
|
|
|
|
|
|
|
_parent => $self, |
1035
|
|
|
|
|
|
|
_type => $self->_termType->lt, |
1036
|
|
|
|
|
|
|
args => $args, |
1037
|
|
|
|
|
|
|
); |
1038
|
|
|
|
|
|
|
|
1039
|
0
|
|
|
|
|
|
return $q; |
1040
|
|
|
|
|
|
|
} |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
sub le { |
1043
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1044
|
0
|
|
|
|
|
|
my ($args) = @_; |
1045
|
|
|
|
|
|
|
|
1046
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1047
|
|
|
|
|
|
|
_parent => $self, |
1048
|
|
|
|
|
|
|
_type => $self->_termType->le, |
1049
|
|
|
|
|
|
|
args => $args, |
1050
|
|
|
|
|
|
|
); |
1051
|
|
|
|
|
|
|
|
1052
|
0
|
|
|
|
|
|
return $q; |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
sub not { |
1056
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1057
|
|
|
|
|
|
|
|
1058
|
0
|
|
|
|
|
|
my $q |
1059
|
|
|
|
|
|
|
= Rethinkdb::Query->new( _parent => $self, _type => $self->_termType->not, |
1060
|
|
|
|
|
|
|
); |
1061
|
|
|
|
|
|
|
|
1062
|
0
|
|
|
|
|
|
return $q; |
1063
|
|
|
|
|
|
|
} |
1064
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
# DATES AND TIMES |
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
sub in_timezone { |
1068
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1069
|
0
|
|
|
|
|
|
my $args = shift; |
1070
|
|
|
|
|
|
|
|
1071
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1072
|
|
|
|
|
|
|
_parent => $self, |
1073
|
|
|
|
|
|
|
_type => $self->_termType->in_timezone, |
1074
|
|
|
|
|
|
|
args => $args, |
1075
|
|
|
|
|
|
|
); |
1076
|
|
|
|
|
|
|
|
1077
|
0
|
|
|
|
|
|
return $q; |
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
sub timezone { |
1081
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1082
|
|
|
|
|
|
|
|
1083
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1084
|
|
|
|
|
|
|
_parent => $self, |
1085
|
|
|
|
|
|
|
_type => $self->_termType->timezone, |
1086
|
|
|
|
|
|
|
); |
1087
|
|
|
|
|
|
|
|
1088
|
0
|
|
|
|
|
|
return $q; |
1089
|
|
|
|
|
|
|
} |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
sub during { |
1092
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1093
|
0
|
|
|
|
|
|
my $start = shift; |
1094
|
0
|
|
|
|
|
|
my $end = shift; |
1095
|
0
|
|
|
|
|
|
my $optargs = shift; |
1096
|
|
|
|
|
|
|
|
1097
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1098
|
|
|
|
|
|
|
_parent => $self, |
1099
|
|
|
|
|
|
|
_type => $self->_termType->during, |
1100
|
|
|
|
|
|
|
args => [ $start, $end ], |
1101
|
|
|
|
|
|
|
optargs => $optargs, |
1102
|
|
|
|
|
|
|
); |
1103
|
|
|
|
|
|
|
|
1104
|
0
|
|
|
|
|
|
return $q; |
1105
|
|
|
|
|
|
|
} |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
sub date { |
1108
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1109
|
|
|
|
|
|
|
|
1110
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1111
|
|
|
|
|
|
|
_parent => $self, |
1112
|
|
|
|
|
|
|
_type => $self->_termType->date, |
1113
|
|
|
|
|
|
|
); |
1114
|
|
|
|
|
|
|
|
1115
|
0
|
|
|
|
|
|
return $q; |
1116
|
|
|
|
|
|
|
} |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
sub time_of_day { |
1119
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1120
|
|
|
|
|
|
|
|
1121
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1122
|
|
|
|
|
|
|
_parent => $self, |
1123
|
|
|
|
|
|
|
_type => $self->_termType->time_of_day, |
1124
|
|
|
|
|
|
|
); |
1125
|
|
|
|
|
|
|
|
1126
|
0
|
|
|
|
|
|
return $q; |
1127
|
|
|
|
|
|
|
} |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
sub year { |
1130
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1131
|
|
|
|
|
|
|
|
1132
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1133
|
|
|
|
|
|
|
_parent => $self, |
1134
|
|
|
|
|
|
|
_type => $self->_termType->year, |
1135
|
|
|
|
|
|
|
); |
1136
|
|
|
|
|
|
|
|
1137
|
0
|
|
|
|
|
|
return $q; |
1138
|
|
|
|
|
|
|
} |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
sub month { |
1141
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1142
|
|
|
|
|
|
|
|
1143
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1144
|
|
|
|
|
|
|
_parent => $self, |
1145
|
|
|
|
|
|
|
_type => $self->_termType->month, |
1146
|
|
|
|
|
|
|
); |
1147
|
|
|
|
|
|
|
|
1148
|
0
|
|
|
|
|
|
return $q; |
1149
|
|
|
|
|
|
|
} |
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
sub day { |
1152
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1153
|
|
|
|
|
|
|
|
1154
|
0
|
|
|
|
|
|
my $q |
1155
|
|
|
|
|
|
|
= Rethinkdb::Query->new( _parent => $self, _type => $self->_termType->day, |
1156
|
|
|
|
|
|
|
); |
1157
|
|
|
|
|
|
|
|
1158
|
0
|
|
|
|
|
|
return $q; |
1159
|
|
|
|
|
|
|
} |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
sub day_of_week { |
1162
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1163
|
|
|
|
|
|
|
|
1164
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1165
|
|
|
|
|
|
|
_parent => $self, |
1166
|
|
|
|
|
|
|
_type => $self->_termType->day_of_week, |
1167
|
|
|
|
|
|
|
); |
1168
|
|
|
|
|
|
|
|
1169
|
0
|
|
|
|
|
|
return $q; |
1170
|
|
|
|
|
|
|
} |
1171
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
sub day_of_year { |
1173
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1174
|
|
|
|
|
|
|
|
1175
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1176
|
|
|
|
|
|
|
_parent => $self, |
1177
|
|
|
|
|
|
|
_type => $self->_termType->day_of_year, |
1178
|
|
|
|
|
|
|
); |
1179
|
|
|
|
|
|
|
|
1180
|
0
|
|
|
|
|
|
return $q; |
1181
|
|
|
|
|
|
|
} |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
sub hours { |
1184
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1185
|
|
|
|
|
|
|
|
1186
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1187
|
|
|
|
|
|
|
_parent => $self, |
1188
|
|
|
|
|
|
|
_type => $self->_termType->hours, |
1189
|
|
|
|
|
|
|
); |
1190
|
|
|
|
|
|
|
|
1191
|
0
|
|
|
|
|
|
return $q; |
1192
|
|
|
|
|
|
|
} |
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
sub minutes { |
1195
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1196
|
|
|
|
|
|
|
|
1197
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1198
|
|
|
|
|
|
|
_parent => $self, |
1199
|
|
|
|
|
|
|
_type => $self->_termType->minutes, |
1200
|
|
|
|
|
|
|
); |
1201
|
|
|
|
|
|
|
|
1202
|
0
|
|
|
|
|
|
return $q; |
1203
|
|
|
|
|
|
|
} |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
sub seconds { |
1206
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1207
|
|
|
|
|
|
|
|
1208
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1209
|
|
|
|
|
|
|
_parent => $self, |
1210
|
|
|
|
|
|
|
_type => $self->_termType->seconds, |
1211
|
|
|
|
|
|
|
); |
1212
|
|
|
|
|
|
|
|
1213
|
0
|
|
|
|
|
|
return $q; |
1214
|
|
|
|
|
|
|
} |
1215
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
sub to_iso8601 { |
1217
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1218
|
|
|
|
|
|
|
|
1219
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1220
|
|
|
|
|
|
|
_parent => $self, |
1221
|
|
|
|
|
|
|
_type => $self->_termType->to_iso8601, |
1222
|
|
|
|
|
|
|
); |
1223
|
|
|
|
|
|
|
|
1224
|
0
|
|
|
|
|
|
return $q; |
1225
|
|
|
|
|
|
|
} |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
sub to_epoch_time { |
1228
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1229
|
|
|
|
|
|
|
|
1230
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1231
|
|
|
|
|
|
|
_parent => $self, |
1232
|
|
|
|
|
|
|
_type => $self->_termType->to_epoch_time, |
1233
|
|
|
|
|
|
|
); |
1234
|
|
|
|
|
|
|
|
1235
|
0
|
|
|
|
|
|
return $q; |
1236
|
|
|
|
|
|
|
} |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
# CONTROL STRUCTURES |
1239
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
# TODO: figure out why the arguments have to be reversed here |
1241
|
|
|
|
|
|
|
sub do { |
1242
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1243
|
0
|
|
|
|
|
|
my ($args) = @_; |
1244
|
|
|
|
|
|
|
|
1245
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1246
|
|
|
|
|
|
|
_rdb => $self->_rdb, |
1247
|
|
|
|
|
|
|
_type => $self->_termType->funcall, |
1248
|
|
|
|
|
|
|
args => [ $args, $self ], |
1249
|
|
|
|
|
|
|
); |
1250
|
|
|
|
|
|
|
|
1251
|
0
|
|
|
|
|
|
return $q; |
1252
|
|
|
|
|
|
|
} |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
sub for_each { |
1255
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1256
|
0
|
|
|
|
|
|
my $args = shift; |
1257
|
|
|
|
|
|
|
|
1258
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1259
|
|
|
|
|
|
|
_parent => $self, |
1260
|
|
|
|
|
|
|
_type => $self->_termType->for_each, |
1261
|
|
|
|
|
|
|
args => $args, |
1262
|
|
|
|
|
|
|
); |
1263
|
|
|
|
|
|
|
|
1264
|
0
|
|
|
|
|
|
return $q; |
1265
|
|
|
|
|
|
|
} |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
sub default { |
1268
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1269
|
0
|
|
|
|
|
|
my $args = shift; |
1270
|
|
|
|
|
|
|
|
1271
|
0
|
0
|
|
|
|
|
if ( !defined $args ) { |
1272
|
0
|
|
|
|
|
|
$args = Rethinkdb::Query::Datum->new( { data => undef } ); |
1273
|
|
|
|
|
|
|
} |
1274
|
|
|
|
|
|
|
|
1275
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1276
|
|
|
|
|
|
|
_parent => $self, |
1277
|
|
|
|
|
|
|
_type => $self->_termType->default, |
1278
|
|
|
|
|
|
|
args => $args, |
1279
|
|
|
|
|
|
|
); |
1280
|
|
|
|
|
|
|
|
1281
|
0
|
|
|
|
|
|
return $q; |
1282
|
|
|
|
|
|
|
} |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
sub coerce_to { |
1285
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1286
|
0
|
|
|
|
|
|
my $args = shift; |
1287
|
|
|
|
|
|
|
|
1288
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1289
|
|
|
|
|
|
|
_parent => $self, |
1290
|
|
|
|
|
|
|
_type => $self->_termType->coerce_to, |
1291
|
|
|
|
|
|
|
args => $args, |
1292
|
|
|
|
|
|
|
); |
1293
|
|
|
|
|
|
|
|
1294
|
0
|
|
|
|
|
|
return $q; |
1295
|
|
|
|
|
|
|
} |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
sub type_of { |
1298
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1299
|
|
|
|
|
|
|
|
1300
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1301
|
|
|
|
|
|
|
_parent => $self, |
1302
|
|
|
|
|
|
|
_type => $self->_termType->type_of, |
1303
|
|
|
|
|
|
|
); |
1304
|
|
|
|
|
|
|
|
1305
|
0
|
|
|
|
|
|
return $q; |
1306
|
|
|
|
|
|
|
} |
1307
|
|
|
|
|
|
|
|
1308
|
|
|
|
|
|
|
sub info { |
1309
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1310
|
|
|
|
|
|
|
|
1311
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1312
|
|
|
|
|
|
|
_parent => $self, |
1313
|
|
|
|
|
|
|
_type => $self->_termType->info, |
1314
|
|
|
|
|
|
|
); |
1315
|
|
|
|
|
|
|
|
1316
|
0
|
|
|
|
|
|
return $q; |
1317
|
|
|
|
|
|
|
} |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
sub fill { |
1320
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1321
|
|
|
|
|
|
|
|
1322
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1323
|
|
|
|
|
|
|
_parent => $self, |
1324
|
|
|
|
|
|
|
_type => $self->_termType->fill, |
1325
|
|
|
|
|
|
|
); |
1326
|
|
|
|
|
|
|
|
1327
|
0
|
|
|
|
|
|
return $q; |
1328
|
|
|
|
|
|
|
} |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
sub to_geojson { |
1331
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1332
|
|
|
|
|
|
|
|
1333
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1334
|
|
|
|
|
|
|
_parent => $self, |
1335
|
|
|
|
|
|
|
_type => $self->_termType->to_geojson, |
1336
|
|
|
|
|
|
|
); |
1337
|
|
|
|
|
|
|
|
1338
|
0
|
|
|
|
|
|
return $q; |
1339
|
|
|
|
|
|
|
} |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
sub includes { |
1342
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1343
|
0
|
|
|
|
|
|
my $args = shift; |
1344
|
|
|
|
|
|
|
|
1345
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1346
|
|
|
|
|
|
|
_parent => $self, |
1347
|
|
|
|
|
|
|
_type => $self->_termType->includes, |
1348
|
|
|
|
|
|
|
args => $args, |
1349
|
|
|
|
|
|
|
); |
1350
|
|
|
|
|
|
|
|
1351
|
0
|
|
|
|
|
|
return $q; |
1352
|
|
|
|
|
|
|
} |
1353
|
|
|
|
|
|
|
|
1354
|
|
|
|
|
|
|
sub intersects { |
1355
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1356
|
0
|
|
|
|
|
|
my $args = shift; |
1357
|
|
|
|
|
|
|
|
1358
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1359
|
|
|
|
|
|
|
_parent => $self, |
1360
|
|
|
|
|
|
|
_type => $self->_termType->intersects, |
1361
|
|
|
|
|
|
|
args => $args, |
1362
|
|
|
|
|
|
|
); |
1363
|
|
|
|
|
|
|
|
1364
|
0
|
|
|
|
|
|
return $q; |
1365
|
|
|
|
|
|
|
} |
1366
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
sub polygon_sub { |
1368
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1369
|
0
|
|
|
|
|
|
my $args = shift; |
1370
|
|
|
|
|
|
|
|
1371
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1372
|
|
|
|
|
|
|
_parent => $self, |
1373
|
|
|
|
|
|
|
_type => $self->_termType->polygon_sub, |
1374
|
|
|
|
|
|
|
args => $args, |
1375
|
|
|
|
|
|
|
); |
1376
|
|
|
|
|
|
|
|
1377
|
0
|
|
|
|
|
|
return $q; |
1378
|
|
|
|
|
|
|
} |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
sub round { |
1381
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1382
|
0
|
|
|
|
|
|
my $args = shift; |
1383
|
|
|
|
|
|
|
|
1384
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1385
|
|
|
|
|
|
|
_parent => $self, |
1386
|
|
|
|
|
|
|
_type => $self->_termType->round, |
1387
|
|
|
|
|
|
|
args => $args |
1388
|
|
|
|
|
|
|
); |
1389
|
|
|
|
|
|
|
|
1390
|
0
|
|
|
|
|
|
return $q; |
1391
|
|
|
|
|
|
|
} |
1392
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
sub ceil { |
1394
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1395
|
0
|
|
|
|
|
|
my $args = shift; |
1396
|
|
|
|
|
|
|
|
1397
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1398
|
|
|
|
|
|
|
_parent => $self, |
1399
|
|
|
|
|
|
|
_type => $self->_termType->ceil, |
1400
|
|
|
|
|
|
|
args => $args |
1401
|
|
|
|
|
|
|
); |
1402
|
|
|
|
|
|
|
|
1403
|
0
|
|
|
|
|
|
return $q; |
1404
|
|
|
|
|
|
|
} |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
sub floor { |
1407
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1408
|
0
|
|
|
|
|
|
my $args = shift; |
1409
|
|
|
|
|
|
|
|
1410
|
0
|
|
|
|
|
|
my $q = Rethinkdb::Query->new( |
1411
|
|
|
|
|
|
|
_parent => $self, |
1412
|
|
|
|
|
|
|
_type => $self->_termType->floor, |
1413
|
|
|
|
|
|
|
args => $args |
1414
|
|
|
|
|
|
|
); |
1415
|
|
|
|
|
|
|
|
1416
|
0
|
|
|
|
|
|
return $q; |
1417
|
|
|
|
|
|
|
} |
1418
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
1; |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
=encoding utf8 |
1422
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
=head1 NAME |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
Rethinkdb::Query - RethinkDB Query |
1426
|
|
|
|
|
|
|
|
1427
|
|
|
|
|
|
|
=head1 SYNOPSIS |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
=head1 DESCRIPTION |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
L is a type of query. |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
1434
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
L implements the following attributes. |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
=head2 args |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
my $query = r->table('marvel')->get(1); |
1440
|
|
|
|
|
|
|
say $query->args; |
1441
|
|
|
|
|
|
|
|
1442
|
|
|
|
|
|
|
The arguments for this instance of a query. |
1443
|
|
|
|
|
|
|
|
1444
|
|
|
|
|
|
|
=head2 optargs |
1445
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
my $query = r->table('marvel')->get_all(1, { index => 'rank' }); |
1447
|
|
|
|
|
|
|
say $query->optargs; |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
The optional arguments for this instance of a query. |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
=head1 METHODS |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
L implements the following methods. |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
=head2 new |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
This is a specialized constructor that enables chaining the queries together |
1458
|
|
|
|
|
|
|
in a rational way. This constructor should never be called directly by |
1459
|
|
|
|
|
|
|
consumers of this library. |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
=head2 run |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
r->table('marvel')->run; |
1464
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
Run a query on a connection. |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
The callback will get either an error, a single JSON result, or a cursor, |
1468
|
|
|
|
|
|
|
depending on the query. |
1469
|
|
|
|
|
|
|
|
1470
|
|
|
|
|
|
|
=head2 update |
1471
|
|
|
|
|
|
|
|
1472
|
|
|
|
|
|
|
r->table('posts')->get(1)->update({status => 'published'})->run; |
1473
|
|
|
|
|
|
|
|
1474
|
|
|
|
|
|
|
Update JSON documents in a table. Accepts a JSON document, a ReQL expression, |
1475
|
|
|
|
|
|
|
or a combination of the two. |
1476
|
|
|
|
|
|
|
|
1477
|
|
|
|
|
|
|
=head2 replace |
1478
|
|
|
|
|
|
|
|
1479
|
|
|
|
|
|
|
r->table('posts')->get(1)->replace({ |
1480
|
|
|
|
|
|
|
id => 1, |
1481
|
|
|
|
|
|
|
title => 'Lorem ipsum', |
1482
|
|
|
|
|
|
|
content => 'Aleas jacta est', |
1483
|
|
|
|
|
|
|
status => 'draft' |
1484
|
|
|
|
|
|
|
})->run; |
1485
|
|
|
|
|
|
|
|
1486
|
|
|
|
|
|
|
Replace documents in a table. Accepts a JSON document or a ReQL expression, and |
1487
|
|
|
|
|
|
|
replaces the original document with the new one. The new document must have the |
1488
|
|
|
|
|
|
|
same primary key as the original document. |
1489
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
=head2 delete |
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
r->table('comments')-> |
1493
|
|
|
|
|
|
|
get('7eab9e63-73f1-4f33-8ce4-95cbea626f59')->delete->run; |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
Delete one or more documents from a table. |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
=head2 filter |
1498
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
r->table('users')->filter({'age' => 30})->run; |
1500
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
Get all the documents for which the given predicate is true. |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
L can be called on a sequence, selection, or a field containing an |
1504
|
|
|
|
|
|
|
array of elements. The return type is the same as the type on which the |
1505
|
|
|
|
|
|
|
function was called on. |
1506
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
The body of every filter is wrapped in an implicit C<< default(r->false) >>, |
1508
|
|
|
|
|
|
|
which means that if a non-existence errors is thrown (when you try to access a |
1509
|
|
|
|
|
|
|
field that does not exist in a document), RethinkDB will just ignore the |
1510
|
|
|
|
|
|
|
document. The C value can be changed by passing the named argument |
1511
|
|
|
|
|
|
|
C. Setting this optional argument to C<< r->error >> will cause any |
1512
|
|
|
|
|
|
|
non-existence errors to return a C. |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
=head2 inner_join |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
r->table('marvel')->inner_join(r->table('dc'), sub($$) { |
1517
|
|
|
|
|
|
|
my ($marvel, $dc) = @_; |
1518
|
|
|
|
|
|
|
return marvel->attr('strength')->lt($dc->attr('strength')); |
1519
|
|
|
|
|
|
|
})->run; |
1520
|
|
|
|
|
|
|
|
1521
|
|
|
|
|
|
|
Returns the inner product of two sequences (e.g. a table, a filter result) |
1522
|
|
|
|
|
|
|
filtered by the predicate. The query compares each row of the left sequence |
1523
|
|
|
|
|
|
|
with each row of the right sequence to find all pairs of rows which satisfy |
1524
|
|
|
|
|
|
|
the predicate. When the predicate is satisfied, each matched pair of rows of |
1525
|
|
|
|
|
|
|
both sequences are combined into a result row. |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
=head2 outer_join |
1528
|
|
|
|
|
|
|
|
1529
|
|
|
|
|
|
|
r->table('marvel')->outer_join(r->table('dc'), sub ($$) { |
1530
|
|
|
|
|
|
|
my ($marvel, $dc) = @_; |
1531
|
|
|
|
|
|
|
return $marvel->attr('strength')->lt($dc->attr('strength')); |
1532
|
|
|
|
|
|
|
})->run; |
1533
|
|
|
|
|
|
|
|
1534
|
|
|
|
|
|
|
Computes a left outer join by retaining each row in the left table even if no |
1535
|
|
|
|
|
|
|
match was found in the right table. |
1536
|
|
|
|
|
|
|
|
1537
|
|
|
|
|
|
|
=head2 eq_join |
1538
|
|
|
|
|
|
|
|
1539
|
|
|
|
|
|
|
r->table('players')->eq_join('gameId', r->table('games'))->run; |
1540
|
|
|
|
|
|
|
|
1541
|
|
|
|
|
|
|
Join tables using a field on the left-hand sequence matching primary keys or |
1542
|
|
|
|
|
|
|
secondary indexes on the right-hand table. L is more efficient than |
1543
|
|
|
|
|
|
|
other ReQL join types, and operates much faster. Documents in the result set |
1544
|
|
|
|
|
|
|
consist of pairs of left-hand and right-hand documents, matched when the |
1545
|
|
|
|
|
|
|
field on the left-hand side exists and is non-null and an entry with that |
1546
|
|
|
|
|
|
|
field's value exists in the specified index on the right-hand side. |
1547
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
=head2 zip |
1549
|
|
|
|
|
|
|
|
1550
|
|
|
|
|
|
|
r->table('marvel')->eq_join('main_dc_collaborator', |
1551
|
|
|
|
|
|
|
r->table('dc'))->zip()->run; |
1552
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
Used to zip up the result of a join by merging the right fields into |
1554
|
|
|
|
|
|
|
left fields of each member of the sequence. |
1555
|
|
|
|
|
|
|
|
1556
|
|
|
|
|
|
|
=head2 map |
1557
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
r->table('marvel')->map(sub { |
1559
|
|
|
|
|
|
|
my $hero = shift; |
1560
|
|
|
|
|
|
|
return $hero->attr('combatPower')->add( |
1561
|
|
|
|
|
|
|
$hero->('compassionPower')->mul(2) |
1562
|
|
|
|
|
|
|
); |
1563
|
|
|
|
|
|
|
})->run; |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
Transform each element of the sequence by applying the given mapping function. |
1566
|
|
|
|
|
|
|
|
1567
|
|
|
|
|
|
|
=head2 with_fields |
1568
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
r->table('users')->with_fields('id', 'username', 'posts')->run; |
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
Plucks one or more attributes from a sequence of objects, filtering out any |
1572
|
|
|
|
|
|
|
objects in the sequence that do not have the specified fields. Functionally, |
1573
|
|
|
|
|
|
|
this is identical to L followed by L on a sequence. |
1574
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
=head2 concat_map |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
r->table('marvel')->concatMap(sub { |
1578
|
|
|
|
|
|
|
my $hero = shift; |
1579
|
|
|
|
|
|
|
return $hero->attr('defeatedMonsters'); |
1580
|
|
|
|
|
|
|
})->run; |
1581
|
|
|
|
|
|
|
|
1582
|
|
|
|
|
|
|
Concatenate one or more elements into a single sequence using a mapping |
1583
|
|
|
|
|
|
|
function. |
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
=head2 order_by |
1586
|
|
|
|
|
|
|
|
1587
|
|
|
|
|
|
|
r->table('posts')->order_by({index => 'date'})->run; |
1588
|
|
|
|
|
|
|
r->table('posts')->order_by({index => r->desc('date')})->run; |
1589
|
|
|
|
|
|
|
|
1590
|
|
|
|
|
|
|
Sort the sequence by document values of the given key(s). To specify the |
1591
|
|
|
|
|
|
|
ordering, wrap the attribute with either Lasc >>|Rethinkdb/asc> or |
1592
|
|
|
|
|
|
|
Ldesc >>|Rethinkdb/desc> (defaults to ascending). |
1593
|
|
|
|
|
|
|
|
1594
|
|
|
|
|
|
|
Sorting without an index requires the server to hold the sequence in memory, |
1595
|
|
|
|
|
|
|
and is limited to 100,000 documents. Sorting with an index can be done on |
1596
|
|
|
|
|
|
|
arbitrarily large tables, or after a L command |
1597
|
|
|
|
|
|
|
using the same index. |
1598
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
=head2 skip |
1600
|
|
|
|
|
|
|
|
1601
|
|
|
|
|
|
|
r->table('marvel')->order_by('successMetric')->skip(10)->run; |
1602
|
|
|
|
|
|
|
|
1603
|
|
|
|
|
|
|
Skip a number of elements from the head of the sequence. |
1604
|
|
|
|
|
|
|
|
1605
|
|
|
|
|
|
|
=head2 limit |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
r->table('marvel')->order_by('belovedness')->limit(10)->run; |
1608
|
|
|
|
|
|
|
|
1609
|
|
|
|
|
|
|
End the sequence after the given number of elements. |
1610
|
|
|
|
|
|
|
|
1611
|
|
|
|
|
|
|
=head2 slice |
1612
|
|
|
|
|
|
|
|
1613
|
|
|
|
|
|
|
r->table('players')->order_by({index => 'age'})->slice(3, 6)->run; |
1614
|
|
|
|
|
|
|
|
1615
|
|
|
|
|
|
|
Return the elements of a sequence within the specified range. |
1616
|
|
|
|
|
|
|
|
1617
|
|
|
|
|
|
|
=head2 nth |
1618
|
|
|
|
|
|
|
|
1619
|
|
|
|
|
|
|
r->expr([1,2,3])->nth(1)->run; |
1620
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
Get the nth element of a sequence. |
1622
|
|
|
|
|
|
|
|
1623
|
|
|
|
|
|
|
=head2 offsets_of |
1624
|
|
|
|
|
|
|
|
1625
|
|
|
|
|
|
|
r->expr(['a','b','c'])->offsets_of('c')->run; |
1626
|
|
|
|
|
|
|
|
1627
|
|
|
|
|
|
|
Get the indexes of an element in a sequence. If the argument is a predicate, |
1628
|
|
|
|
|
|
|
get the indexes of all elements matching it. |
1629
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
=head2 is_empty |
1631
|
|
|
|
|
|
|
|
1632
|
|
|
|
|
|
|
r->table('marvel')->is_empty->run; |
1633
|
|
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
Test if a sequence is empty. |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
=head2 union |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
r->table('marvel')->union(r->table('dc'))->run; |
1639
|
|
|
|
|
|
|
|
1640
|
|
|
|
|
|
|
Concatenate two sequences. |
1641
|
|
|
|
|
|
|
|
1642
|
|
|
|
|
|
|
=head2 sample |
1643
|
|
|
|
|
|
|
|
1644
|
|
|
|
|
|
|
r->table('marvel')->sample(3)->run; |
1645
|
|
|
|
|
|
|
|
1646
|
|
|
|
|
|
|
Select a given number of elements from a sequence with uniform random |
1647
|
|
|
|
|
|
|
distribution. Selection is done without replacement. |
1648
|
|
|
|
|
|
|
|
1649
|
|
|
|
|
|
|
=head2 group |
1650
|
|
|
|
|
|
|
|
1651
|
|
|
|
|
|
|
r->table('games')->group('player')->max('points')->run; |
1652
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
Takes a stream and partitions it into multiple groups based on the fields or |
1654
|
|
|
|
|
|
|
functions provided. Commands chained after L will be called on each of |
1655
|
|
|
|
|
|
|
these grouped sub-streams, producing grouped data. |
1656
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
=head2 ungroup |
1658
|
|
|
|
|
|
|
|
1659
|
|
|
|
|
|
|
r->table('games') |
1660
|
|
|
|
|
|
|
->group('player')->max('points')->attr('points') |
1661
|
|
|
|
|
|
|
->ungroup()->order_by(r->desc('reduction'))->run; |
1662
|
|
|
|
|
|
|
|
1663
|
|
|
|
|
|
|
Takes a grouped stream or grouped data and turns it into an array of objects |
1664
|
|
|
|
|
|
|
representing the groups. Any commands chained after L will operate on |
1665
|
|
|
|
|
|
|
this array, rather than operating on each group individually. This is useful |
1666
|
|
|
|
|
|
|
if you want to e.g. order the groups by the value of their reduction. |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
=head2 reduce |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
r->table('posts')->map(sub { return 1; })->reduce(sub($$) { |
1671
|
|
|
|
|
|
|
my ($left, $right) = @_; |
1672
|
|
|
|
|
|
|
return $left->add($right); |
1673
|
|
|
|
|
|
|
})->run; |
1674
|
|
|
|
|
|
|
|
1675
|
|
|
|
|
|
|
Produce a single value from a sequence through repeated application of a |
1676
|
|
|
|
|
|
|
reduction function. |
1677
|
|
|
|
|
|
|
|
1678
|
|
|
|
|
|
|
=head2 fold |
1679
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
r->table('words')->order_by('id')->fold( |
1681
|
|
|
|
|
|
|
'', |
1682
|
|
|
|
|
|
|
sub ($$) { |
1683
|
|
|
|
|
|
|
my ( $acc, $word ) = @_; |
1684
|
|
|
|
|
|
|
return $acc->add( r->branch( $acc->eq(''), '', ', ' )->add($word) ); |
1685
|
|
|
|
|
|
|
} |
1686
|
|
|
|
|
|
|
)->run; |
1687
|
|
|
|
|
|
|
|
1688
|
|
|
|
|
|
|
r->table('tracker')->filter( { name => 'bob' } )->order_by('date') |
1689
|
|
|
|
|
|
|
->bracket('weight')->fold( |
1690
|
|
|
|
|
|
|
[], |
1691
|
|
|
|
|
|
|
sub ($$) { |
1692
|
|
|
|
|
|
|
my ( $acc, $row ) = @_; |
1693
|
|
|
|
|
|
|
return $acc->append($row)->limit(5); |
1694
|
|
|
|
|
|
|
}, |
1695
|
|
|
|
|
|
|
sub ($$$) { |
1696
|
|
|
|
|
|
|
my ( $acc, $row, $new_acc ) = @_; |
1697
|
|
|
|
|
|
|
return r->branch( new_acc->size()->eq(5), [ new_acc->avg() ], [] ); |
1698
|
|
|
|
|
|
|
} |
1699
|
|
|
|
|
|
|
)->run; |
1700
|
|
|
|
|
|
|
|
1701
|
|
|
|
|
|
|
Apply a function to a sequence in order, maintaining state via an accumulator. |
1702
|
|
|
|
|
|
|
The fold command returns either a single value or a new sequence. |
1703
|
|
|
|
|
|
|
|
1704
|
|
|
|
|
|
|
=head2 count |
1705
|
|
|
|
|
|
|
|
1706
|
|
|
|
|
|
|
r->table('marvel')->count->add(r->table('dc')->count->run |
1707
|
|
|
|
|
|
|
|
1708
|
|
|
|
|
|
|
Count the number of elements in the sequence. With a single argument, count the |
1709
|
|
|
|
|
|
|
number of elements equal to it. If the argument is a function, it is equivalent |
1710
|
|
|
|
|
|
|
to calling filter before count. |
1711
|
|
|
|
|
|
|
|
1712
|
|
|
|
|
|
|
=head2 sum |
1713
|
|
|
|
|
|
|
|
1714
|
|
|
|
|
|
|
r->expr([3, 5, 7])->sum->run; |
1715
|
|
|
|
|
|
|
|
1716
|
|
|
|
|
|
|
Sums all the elements of a sequence. If called with a field name, sums all the |
1717
|
|
|
|
|
|
|
values of that field in the sequence, skipping elements of the sequence that |
1718
|
|
|
|
|
|
|
lack that field. If called with a function, calls that function on every |
1719
|
|
|
|
|
|
|
element of the sequence and sums the results, skipping elements of the sequence |
1720
|
|
|
|
|
|
|
where that function returns C or a non-existence error. |
1721
|
|
|
|
|
|
|
|
1722
|
|
|
|
|
|
|
=head2 avg |
1723
|
|
|
|
|
|
|
|
1724
|
|
|
|
|
|
|
r->expr([3, 5, 7])->avg->run; |
1725
|
|
|
|
|
|
|
|
1726
|
|
|
|
|
|
|
Averages all the elements of a sequence. If called with a field name, averages |
1727
|
|
|
|
|
|
|
all the values of that field in the sequence, skipping elements of the sequence |
1728
|
|
|
|
|
|
|
that lack that field. If called with a function, calls that function on every |
1729
|
|
|
|
|
|
|
element of the sequence and averages the results, skipping elements of the |
1730
|
|
|
|
|
|
|
sequence where that function returns C or a non-existence error. |
1731
|
|
|
|
|
|
|
|
1732
|
|
|
|
|
|
|
=head2 min |
1733
|
|
|
|
|
|
|
|
1734
|
|
|
|
|
|
|
r->expr([3, 5, 7])->min->run; |
1735
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
Finds the minimum of a sequence. If called with a field name, finds the element |
1737
|
|
|
|
|
|
|
of that sequence with the smallest value in that field. If called with a |
1738
|
|
|
|
|
|
|
function, calls that function on every element of the sequence and returns the |
1739
|
|
|
|
|
|
|
element which produced the smallest value, ignoring any elements where the |
1740
|
|
|
|
|
|
|
function returns C or produces a non-existence error. |
1741
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
=head2 max |
1743
|
|
|
|
|
|
|
|
1744
|
|
|
|
|
|
|
r->expr([3, 5, 7])->max->run; |
1745
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
Finds the maximum of a sequence. If called with a field name, finds the element |
1747
|
|
|
|
|
|
|
of that sequence with the largest value in that field. If called with a |
1748
|
|
|
|
|
|
|
function, calls that function on every element of the sequence and returns the |
1749
|
|
|
|
|
|
|
element which produced the largest value, ignoring any elements where the |
1750
|
|
|
|
|
|
|
function returns null or produces a non-existence error. |
1751
|
|
|
|
|
|
|
|
1752
|
|
|
|
|
|
|
=head2 distinct |
1753
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
r->table('marvel')->concat_map(sub { |
1755
|
|
|
|
|
|
|
my $hero = shift; |
1756
|
|
|
|
|
|
|
return $hero->attr('villainList') |
1757
|
|
|
|
|
|
|
})->distinct->run; |
1758
|
|
|
|
|
|
|
|
1759
|
|
|
|
|
|
|
Remove duplicate elements from the sequence. |
1760
|
|
|
|
|
|
|
|
1761
|
|
|
|
|
|
|
=head2 contains |
1762
|
|
|
|
|
|
|
|
1763
|
|
|
|
|
|
|
r->table('marvel')->get('ironman')-> |
1764
|
|
|
|
|
|
|
attr('opponents')->contains('superman')->run; |
1765
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
Returns whether or not a sequence contains all the specified values, or if |
1767
|
|
|
|
|
|
|
functions are provided instead, returns whether or not a sequence contains |
1768
|
|
|
|
|
|
|
values matching all the specified functions. |
1769
|
|
|
|
|
|
|
|
1770
|
|
|
|
|
|
|
=head2 pluck |
1771
|
|
|
|
|
|
|
|
1772
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')-> |
1773
|
|
|
|
|
|
|
pluck('reactorState', 'reactorPower')->run; |
1774
|
|
|
|
|
|
|
|
1775
|
|
|
|
|
|
|
Plucks out one or more attributes from either an object or a sequence of |
1776
|
|
|
|
|
|
|
objects (projection). |
1777
|
|
|
|
|
|
|
|
1778
|
|
|
|
|
|
|
=head2 without |
1779
|
|
|
|
|
|
|
|
1780
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->without('personalVictoriesList')->run; |
1781
|
|
|
|
|
|
|
|
1782
|
|
|
|
|
|
|
The opposite of pluck; takes an object or a sequence of objects, and returns |
1783
|
|
|
|
|
|
|
them with the specified paths removed. |
1784
|
|
|
|
|
|
|
|
1785
|
|
|
|
|
|
|
=head2 merge |
1786
|
|
|
|
|
|
|
|
1787
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->merge( |
1788
|
|
|
|
|
|
|
r->table('loadouts')->get('alienInvasionKit') |
1789
|
|
|
|
|
|
|
)->run; |
1790
|
|
|
|
|
|
|
|
1791
|
|
|
|
|
|
|
Merge two objects together to construct a new object with properties from both. |
1792
|
|
|
|
|
|
|
Gives preference to attributes from other when there is a conflict. |
1793
|
|
|
|
|
|
|
|
1794
|
|
|
|
|
|
|
=head2 append |
1795
|
|
|
|
|
|
|
|
1796
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')-> |
1797
|
|
|
|
|
|
|
attr('equipment')->append('newBoots')->run; |
1798
|
|
|
|
|
|
|
|
1799
|
|
|
|
|
|
|
Append a value to an array. |
1800
|
|
|
|
|
|
|
|
1801
|
|
|
|
|
|
|
=head2 prepend |
1802
|
|
|
|
|
|
|
|
1803
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')-> |
1804
|
|
|
|
|
|
|
attr('equipment')->prepend('newBoots')->run; |
1805
|
|
|
|
|
|
|
|
1806
|
|
|
|
|
|
|
Prepend a value to an array. |
1807
|
|
|
|
|
|
|
|
1808
|
|
|
|
|
|
|
=head2 difference |
1809
|
|
|
|
|
|
|
|
1810
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')-> |
1811
|
|
|
|
|
|
|
attr('equipment')->difference(['Boots'])->run; |
1812
|
|
|
|
|
|
|
|
1813
|
|
|
|
|
|
|
Remove the elements of one array from another array. |
1814
|
|
|
|
|
|
|
|
1815
|
|
|
|
|
|
|
=head2 set_insert |
1816
|
|
|
|
|
|
|
|
1817
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')-> |
1818
|
|
|
|
|
|
|
attr('equipment')->set_insert('newBoots')->run; |
1819
|
|
|
|
|
|
|
|
1820
|
|
|
|
|
|
|
Add a value to an array and return it as a set (an array with distinct values). |
1821
|
|
|
|
|
|
|
|
1822
|
|
|
|
|
|
|
=head2 set_union |
1823
|
|
|
|
|
|
|
|
1824
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')-> |
1825
|
|
|
|
|
|
|
attr('equipment')->set_union(['newBoots', 'arc_reactor'])->run; |
1826
|
|
|
|
|
|
|
|
1827
|
|
|
|
|
|
|
Add a several values to an array and return it as a set (an array with distinct |
1828
|
|
|
|
|
|
|
values). |
1829
|
|
|
|
|
|
|
|
1830
|
|
|
|
|
|
|
=head2 set_intersection |
1831
|
|
|
|
|
|
|
|
1832
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->attr('equipment')-> |
1833
|
|
|
|
|
|
|
set_intersection(['newBoots', 'arc_reactor'])->run; |
1834
|
|
|
|
|
|
|
|
1835
|
|
|
|
|
|
|
Intersect two arrays returning values that occur in both of them as a set (an |
1836
|
|
|
|
|
|
|
array with distinct values). |
1837
|
|
|
|
|
|
|
|
1838
|
|
|
|
|
|
|
=head2 set_difference |
1839
|
|
|
|
|
|
|
|
1840
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->attr('equipment')-> |
1841
|
|
|
|
|
|
|
set_difference(['newBoots', 'arc_reactor'])->run; |
1842
|
|
|
|
|
|
|
|
1843
|
|
|
|
|
|
|
Remove the elements of one array from another and return them as a set (an |
1844
|
|
|
|
|
|
|
array with distinct values). |
1845
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
=head2 get_field |
1847
|
|
|
|
|
|
|
|
1848
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->get_field('firstAppearance')->run; |
1849
|
|
|
|
|
|
|
|
1850
|
|
|
|
|
|
|
Get a single field from an object. If called on a sequence, gets that field |
1851
|
|
|
|
|
|
|
from every object in the sequence, skipping objects that lack it. |
1852
|
|
|
|
|
|
|
|
1853
|
|
|
|
|
|
|
=head2 bracket |
1854
|
|
|
|
|
|
|
|
1855
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->bracket('firstAppearance')->run; |
1856
|
|
|
|
|
|
|
r->expr([10, 20, 30, 40, 50])->bracket(3)->run; |
1857
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
Get a single field from an object or a single element from a sequence. |
1859
|
|
|
|
|
|
|
|
1860
|
|
|
|
|
|
|
=head2 attr |
1861
|
|
|
|
|
|
|
|
1862
|
|
|
|
|
|
|
r->table('marvel')->get('IronMan')->attr('firstAppearance')->run; |
1863
|
|
|
|
|
|
|
r->expr([10, 20, 30, 40, 50])->attr(3)->run; |
1864
|
|
|
|
|
|
|
|
1865
|
|
|
|
|
|
|
Get a single field from an object or a single element from a sequence. |
1866
|
|
|
|
|
|
|
|
1867
|
|
|
|
|
|
|
DEPERCATED: This method has been renamed to L, but L will |
1868
|
|
|
|
|
|
|
remain for a number of releases for backwards compatibility. |
1869
|
|
|
|
|
|
|
|
1870
|
|
|
|
|
|
|
=head2 has_fields |
1871
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
r->table('players')->has_fields('games_won')->run; |
1873
|
|
|
|
|
|
|
|
1874
|
|
|
|
|
|
|
Test if an object has one or more fields. An object has a field if it has that |
1875
|
|
|
|
|
|
|
key and the key has a non-null value. For instance, the object |
1876
|
|
|
|
|
|
|
C<< {'a' => 1, 'b' => 2, 'c' => null} >> has the fields C and C. |
1877
|
|
|
|
|
|
|
|
1878
|
|
|
|
|
|
|
=head2 insert_at |
1879
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
r->expr(['Iron Man', 'Spider-Man'])->insert_at(1, 'Hulk')->run; |
1881
|
|
|
|
|
|
|
|
1882
|
|
|
|
|
|
|
Insert a value in to an array at a given index. Returns the modified array. |
1883
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
=head2 splice_at |
1885
|
|
|
|
|
|
|
|
1886
|
|
|
|
|
|
|
r->expr(['Iron Man', 'Spider-Man'])->splice_at(1, ['Hulk', 'Thor'])->run; |
1887
|
|
|
|
|
|
|
|
1888
|
|
|
|
|
|
|
Insert several values in to an array at a given index. Returns the modified |
1889
|
|
|
|
|
|
|
array. |
1890
|
|
|
|
|
|
|
|
1891
|
|
|
|
|
|
|
=head2 delete_at |
1892
|
|
|
|
|
|
|
|
1893
|
|
|
|
|
|
|
r->expr(['a','b','c','d','e','f'])->delete_at(1)->run; |
1894
|
|
|
|
|
|
|
|
1895
|
|
|
|
|
|
|
Remove one or more elements from an array at a given index. Returns the |
1896
|
|
|
|
|
|
|
modified array. |
1897
|
|
|
|
|
|
|
|
1898
|
|
|
|
|
|
|
=head2 change_at |
1899
|
|
|
|
|
|
|
|
1900
|
|
|
|
|
|
|
r->expr(['Iron Man', 'Bruce', 'Spider-Man'])->change_at(1, 'Hulk')->run; |
1901
|
|
|
|
|
|
|
|
1902
|
|
|
|
|
|
|
Change a value in an array at a given index. Returns the modified array. |
1903
|
|
|
|
|
|
|
|
1904
|
|
|
|
|
|
|
=head2 keys |
1905
|
|
|
|
|
|
|
|
1906
|
|
|
|
|
|
|
r->table('marvel')->get('ironman')->keys->run; |
1907
|
|
|
|
|
|
|
|
1908
|
|
|
|
|
|
|
Return an array containing all of the object's keys. |
1909
|
|
|
|
|
|
|
|
1910
|
|
|
|
|
|
|
=head2 values |
1911
|
|
|
|
|
|
|
|
1912
|
|
|
|
|
|
|
r->table('marvel')->get('ironman')->values->run; |
1913
|
|
|
|
|
|
|
|
1914
|
|
|
|
|
|
|
Return an array containing all of an object’s values. C guarantees the |
1915
|
|
|
|
|
|
|
values will come out in the same order as L. |
1916
|
|
|
|
|
|
|
|
1917
|
|
|
|
|
|
|
=head2 match |
1918
|
|
|
|
|
|
|
|
1919
|
|
|
|
|
|
|
r->table('users')->filter(sub { |
1920
|
|
|
|
|
|
|
my $doc = shift; |
1921
|
|
|
|
|
|
|
return $doc->attr('name')->match('^A') |
1922
|
|
|
|
|
|
|
})->run; |
1923
|
|
|
|
|
|
|
|
1924
|
|
|
|
|
|
|
Matches against a regular expression. If there is a match, returns an object |
1925
|
|
|
|
|
|
|
with the fields: |
1926
|
|
|
|
|
|
|
|
1927
|
|
|
|
|
|
|
=head2 split |
1928
|
|
|
|
|
|
|
|
1929
|
|
|
|
|
|
|
r->expr('foo bar bax')->split->run; |
1930
|
|
|
|
|
|
|
r->expr('foo,bar,bax')->split(",")->run; |
1931
|
|
|
|
|
|
|
r->expr('foo,bar,bax')->split(",", 1)->run; |
1932
|
|
|
|
|
|
|
|
1933
|
|
|
|
|
|
|
Splits a string into substrings. Splits on whitespace when called with no |
1934
|
|
|
|
|
|
|
arguments. When called with a separator, splits on that separator. When called |
1935
|
|
|
|
|
|
|
with a separator and a maximum number of splits, splits on that separator at |
1936
|
|
|
|
|
|
|
most C times. (Can be called with C as the separator if you |
1937
|
|
|
|
|
|
|
want to split on whitespace while still specifying C.) |
1938
|
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
Mimics the behavior of Python's C in edge cases, except for |
1940
|
|
|
|
|
|
|
splitting on the empty string, which instead produces an array of |
1941
|
|
|
|
|
|
|
single-character strings. |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
=head2 upcase |
1944
|
|
|
|
|
|
|
|
1945
|
|
|
|
|
|
|
r->expr('Sentence about LaTeX.')->upcase->run; |
1946
|
|
|
|
|
|
|
|
1947
|
|
|
|
|
|
|
Uppercases a string. |
1948
|
|
|
|
|
|
|
|
1949
|
|
|
|
|
|
|
=head2 downcase |
1950
|
|
|
|
|
|
|
|
1951
|
|
|
|
|
|
|
r->expr('Sentence about LaTeX.')->downcase->run; |
1952
|
|
|
|
|
|
|
|
1953
|
|
|
|
|
|
|
Lowercases a string. |
1954
|
|
|
|
|
|
|
|
1955
|
|
|
|
|
|
|
=head2 add |
1956
|
|
|
|
|
|
|
|
1957
|
|
|
|
|
|
|
r->expr(2)->add(2)->run; |
1958
|
|
|
|
|
|
|
|
1959
|
|
|
|
|
|
|
Sum two numbers, concatenate two strings, or concatenate 2 arrays. |
1960
|
|
|
|
|
|
|
|
1961
|
|
|
|
|
|
|
=head2 sub |
1962
|
|
|
|
|
|
|
|
1963
|
|
|
|
|
|
|
r->expr(2)->sub(2)->run; |
1964
|
|
|
|
|
|
|
|
1965
|
|
|
|
|
|
|
Subtract two numbers. |
1966
|
|
|
|
|
|
|
|
1967
|
|
|
|
|
|
|
=head2 mul |
1968
|
|
|
|
|
|
|
|
1969
|
|
|
|
|
|
|
r->expr(2)->mul(2)->run; |
1970
|
|
|
|
|
|
|
|
1971
|
|
|
|
|
|
|
Multiply two numbers, or make a periodic array. |
1972
|
|
|
|
|
|
|
|
1973
|
|
|
|
|
|
|
=head2 div |
1974
|
|
|
|
|
|
|
|
1975
|
|
|
|
|
|
|
r->expr(2)->div(2)->run; |
1976
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
Divide two numbers. |
1978
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
=head2 mod |
1980
|
|
|
|
|
|
|
|
1981
|
|
|
|
|
|
|
r->expr(2)->mod(2)->run; |
1982
|
|
|
|
|
|
|
|
1983
|
|
|
|
|
|
|
Find the remainder when dividing two numbers. |
1984
|
|
|
|
|
|
|
|
1985
|
|
|
|
|
|
|
=head2 and |
1986
|
|
|
|
|
|
|
|
1987
|
|
|
|
|
|
|
r->expr(r->true)->and(r->false)->run; |
1988
|
|
|
|
|
|
|
|
1989
|
|
|
|
|
|
|
Compute the logical C of two or more values. |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
=head2 or |
1992
|
|
|
|
|
|
|
|
1993
|
|
|
|
|
|
|
r->expr(r->true)->or(r->false)->run; |
1994
|
|
|
|
|
|
|
|
1995
|
|
|
|
|
|
|
Compute the logical C of two or more values. |
1996
|
|
|
|
|
|
|
|
1997
|
|
|
|
|
|
|
=head2 eq |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
r->expr(2)->eq(2)->run; |
2000
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
Test if two values are equal. |
2002
|
|
|
|
|
|
|
|
2003
|
|
|
|
|
|
|
=head2 ne |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
r->expr(2)->ne(2)->run; |
2006
|
|
|
|
|
|
|
|
2007
|
|
|
|
|
|
|
Test if two values are not equal. |
2008
|
|
|
|
|
|
|
|
2009
|
|
|
|
|
|
|
=head2 gt |
2010
|
|
|
|
|
|
|
|
2011
|
|
|
|
|
|
|
r->expr(2)->gt(2)->run; |
2012
|
|
|
|
|
|
|
|
2013
|
|
|
|
|
|
|
Test if the first value is greater than other. |
2014
|
|
|
|
|
|
|
|
2015
|
|
|
|
|
|
|
=head2 ge |
2016
|
|
|
|
|
|
|
|
2017
|
|
|
|
|
|
|
r->expr(2)->ge(2)->run; |
2018
|
|
|
|
|
|
|
|
2019
|
|
|
|
|
|
|
Test if the first value is greater than or equal to other. |
2020
|
|
|
|
|
|
|
|
2021
|
|
|
|
|
|
|
=head2 lt |
2022
|
|
|
|
|
|
|
|
2023
|
|
|
|
|
|
|
r->expr(2)->lt(2)->run; |
2024
|
|
|
|
|
|
|
|
2025
|
|
|
|
|
|
|
Test if the first value is less than other. |
2026
|
|
|
|
|
|
|
|
2027
|
|
|
|
|
|
|
=head2 le |
2028
|
|
|
|
|
|
|
|
2029
|
|
|
|
|
|
|
r->expr(2)->le(2)->run; |
2030
|
|
|
|
|
|
|
|
2031
|
|
|
|
|
|
|
Test if the first value is less than or equal to other. |
2032
|
|
|
|
|
|
|
|
2033
|
|
|
|
|
|
|
=head2 not |
2034
|
|
|
|
|
|
|
|
2035
|
|
|
|
|
|
|
r->expr(r->true)->not->run; |
2036
|
|
|
|
|
|
|
|
2037
|
|
|
|
|
|
|
Compute the logical inverse (not) of an expression. |
2038
|
|
|
|
|
|
|
|
2039
|
|
|
|
|
|
|
=head2 in_timezone |
2040
|
|
|
|
|
|
|
|
2041
|
|
|
|
|
|
|
r->now->in_timezone('-08:00')->hours->run; |
2042
|
|
|
|
|
|
|
|
2043
|
|
|
|
|
|
|
Return a new time object with a different timezone. While the time stays the |
2044
|
|
|
|
|
|
|
same, the results returned by methods such as L will change since they |
2045
|
|
|
|
|
|
|
take the timezone into account. The timezone argument has to be of the ISO 8601 |
2046
|
|
|
|
|
|
|
format. |
2047
|
|
|
|
|
|
|
|
2048
|
|
|
|
|
|
|
=head2 timezone |
2049
|
|
|
|
|
|
|
|
2050
|
|
|
|
|
|
|
r->table('users')->filter(sub { |
2051
|
|
|
|
|
|
|
my $user = shift; |
2052
|
|
|
|
|
|
|
return $user->attr('subscriptionDate')->timezone->eql('-07:00'); |
2053
|
|
|
|
|
|
|
})->run; |
2054
|
|
|
|
|
|
|
|
2055
|
|
|
|
|
|
|
Return the timezone of the time object. |
2056
|
|
|
|
|
|
|
|
2057
|
|
|
|
|
|
|
=head2 during |
2058
|
|
|
|
|
|
|
|
2059
|
|
|
|
|
|
|
r->table('posts')->filter( |
2060
|
|
|
|
|
|
|
r->row->attr('date')->during( |
2061
|
|
|
|
|
|
|
r->time(2013, 12, 1, 'Z'), |
2062
|
|
|
|
|
|
|
r->time(2013, 12, 10, 'Z') |
2063
|
|
|
|
|
|
|
) |
2064
|
|
|
|
|
|
|
)->run; |
2065
|
|
|
|
|
|
|
|
2066
|
|
|
|
|
|
|
Return if a time is between two other times (by default, inclusive for the |
2067
|
|
|
|
|
|
|
start, exclusive for the end). |
2068
|
|
|
|
|
|
|
|
2069
|
|
|
|
|
|
|
=head2 date |
2070
|
|
|
|
|
|
|
|
2071
|
|
|
|
|
|
|
r->table('users')->filter(sub { |
2072
|
|
|
|
|
|
|
my $user = shift; |
2073
|
|
|
|
|
|
|
return user->attr('birthdate')->date->eql(r->now->date); |
2074
|
|
|
|
|
|
|
})->run; |
2075
|
|
|
|
|
|
|
|
2076
|
|
|
|
|
|
|
Return a new time object only based on the day, month and year (ie. the same |
2077
|
|
|
|
|
|
|
day at 00:00). |
2078
|
|
|
|
|
|
|
|
2079
|
|
|
|
|
|
|
=head2 time_of_day |
2080
|
|
|
|
|
|
|
|
2081
|
|
|
|
|
|
|
r->table('posts')->filter( |
2082
|
|
|
|
|
|
|
r->row->attr('date')->time_of_day->le(12*60*60) |
2083
|
|
|
|
|
|
|
)->run; |
2084
|
|
|
|
|
|
|
|
2085
|
|
|
|
|
|
|
Return the number of seconds elapsed since the beginning of the day stored in |
2086
|
|
|
|
|
|
|
the time object. |
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
=head2 year |
2089
|
|
|
|
|
|
|
|
2090
|
|
|
|
|
|
|
r->table('users')->filter(sub { |
2091
|
|
|
|
|
|
|
my $user = shift; |
2092
|
|
|
|
|
|
|
return user->attr('birthdate')->year->eql(1986); |
2093
|
|
|
|
|
|
|
})->run; |
2094
|
|
|
|
|
|
|
|
2095
|
|
|
|
|
|
|
Return the year of a time object. |
2096
|
|
|
|
|
|
|
|
2097
|
|
|
|
|
|
|
=head2 month |
2098
|
|
|
|
|
|
|
|
2099
|
|
|
|
|
|
|
r->table('users')->filter( |
2100
|
|
|
|
|
|
|
r->row->attr('birthdate')->month->eql(11) |
2101
|
|
|
|
|
|
|
)->run; |
2102
|
|
|
|
|
|
|
|
2103
|
|
|
|
|
|
|
Return the month of a time object as a number between 1 and 12. For your |
2104
|
|
|
|
|
|
|
convenience, the terms Ljanuary >>|Rethinkdb/january>, |
2105
|
|
|
|
|
|
|
Lfebruary >>|Rethinkdb/february> etc. are defined and map to the |
2106
|
|
|
|
|
|
|
appropriate integer. |
2107
|
|
|
|
|
|
|
|
2108
|
|
|
|
|
|
|
=head2 day |
2109
|
|
|
|
|
|
|
|
2110
|
|
|
|
|
|
|
r->table('users')->filter( |
2111
|
|
|
|
|
|
|
r->row->attr('birthdate')->day->eql(24) |
2112
|
|
|
|
|
|
|
)->run; |
2113
|
|
|
|
|
|
|
|
2114
|
|
|
|
|
|
|
Return the day of a time object as a number between 1 and 31. |
2115
|
|
|
|
|
|
|
|
2116
|
|
|
|
|
|
|
=head2 day_of_week |
2117
|
|
|
|
|
|
|
|
2118
|
|
|
|
|
|
|
r->now->day_of_week->run; |
2119
|
|
|
|
|
|
|
|
2120
|
|
|
|
|
|
|
Return the day of week of a time object as a number between 1 and 7 (following |
2121
|
|
|
|
|
|
|
ISO 8601 standard). For your convenience, the terms r.monday, r.tuesday etc. |
2122
|
|
|
|
|
|
|
are defined and map to the appropriate integer. |
2123
|
|
|
|
|
|
|
|
2124
|
|
|
|
|
|
|
=head2 day_of_year |
2125
|
|
|
|
|
|
|
|
2126
|
|
|
|
|
|
|
r->now->day_of_year->run; |
2127
|
|
|
|
|
|
|
|
2128
|
|
|
|
|
|
|
Return the day of the year of a time object as a number between 1 and 366 |
2129
|
|
|
|
|
|
|
(following ISO 8601 standard). |
2130
|
|
|
|
|
|
|
|
2131
|
|
|
|
|
|
|
=head2 hours |
2132
|
|
|
|
|
|
|
|
2133
|
|
|
|
|
|
|
r->table('posts')->filter(sub { |
2134
|
|
|
|
|
|
|
my $post = shift; |
2135
|
|
|
|
|
|
|
return $post->attr('date')->hours->lt(4); |
2136
|
|
|
|
|
|
|
})->run; |
2137
|
|
|
|
|
|
|
|
2138
|
|
|
|
|
|
|
Return the hour in a time object as a number between 0 and 23. |
2139
|
|
|
|
|
|
|
|
2140
|
|
|
|
|
|
|
=head2 minutes |
2141
|
|
|
|
|
|
|
|
2142
|
|
|
|
|
|
|
r->table('posts')->filter(sub { |
2143
|
|
|
|
|
|
|
my $post = shift; |
2144
|
|
|
|
|
|
|
return $post->attr('date')->minutes->lt(10); |
2145
|
|
|
|
|
|
|
})->run; |
2146
|
|
|
|
|
|
|
|
2147
|
|
|
|
|
|
|
Return the minute in a time object as a number between 0 and 59. |
2148
|
|
|
|
|
|
|
|
2149
|
|
|
|
|
|
|
=head2 seconds |
2150
|
|
|
|
|
|
|
|
2151
|
|
|
|
|
|
|
r->table('posts')->filter(sub { |
2152
|
|
|
|
|
|
|
my $post = shift; |
2153
|
|
|
|
|
|
|
return $post->attr('date')->seconds->lt(30); |
2154
|
|
|
|
|
|
|
})->run; |
2155
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
Return the seconds in a time object as a number between 0 and 59.999 (double |
2157
|
|
|
|
|
|
|
precision). |
2158
|
|
|
|
|
|
|
|
2159
|
|
|
|
|
|
|
=head2 to_iso8601 |
2160
|
|
|
|
|
|
|
|
2161
|
|
|
|
|
|
|
r->now->to_iso8601->run; |
2162
|
|
|
|
|
|
|
|
2163
|
|
|
|
|
|
|
Convert a time object to its ISO 8601 format. |
2164
|
|
|
|
|
|
|
|
2165
|
|
|
|
|
|
|
=head2 to_epoch_time |
2166
|
|
|
|
|
|
|
|
2167
|
|
|
|
|
|
|
r->now->to_epoch_time->run; |
2168
|
|
|
|
|
|
|
|
2169
|
|
|
|
|
|
|
Convert a time object to its epoch time. |
2170
|
|
|
|
|
|
|
|
2171
|
|
|
|
|
|
|
=head2 do |
2172
|
|
|
|
|
|
|
|
2173
|
|
|
|
|
|
|
r->table('players')->get('86be93eb-a112-48f5-a829-15b2cb49de1d')->do(sub { |
2174
|
|
|
|
|
|
|
my $player = shift; |
2175
|
|
|
|
|
|
|
return $player->attr('gross_score')->sub($player->attr('course_handicap')); |
2176
|
|
|
|
|
|
|
})->run |
2177
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
Evaluate an expression and pass its values as arguments to a function or to an |
2179
|
|
|
|
|
|
|
expression. |
2180
|
|
|
|
|
|
|
|
2181
|
|
|
|
|
|
|
=head2 for_each |
2182
|
|
|
|
|
|
|
|
2183
|
|
|
|
|
|
|
r->table('marvel')->for_each(sub { |
2184
|
|
|
|
|
|
|
my $hero = shift; |
2185
|
|
|
|
|
|
|
r->table('villains')->get($hero->attr('villainDefeated'))->delete; |
2186
|
|
|
|
|
|
|
})->run; |
2187
|
|
|
|
|
|
|
|
2188
|
|
|
|
|
|
|
Loop over a sequence, evaluating the given write query for each element. |
2189
|
|
|
|
|
|
|
|
2190
|
|
|
|
|
|
|
=head2 default |
2191
|
|
|
|
|
|
|
|
2192
|
|
|
|
|
|
|
r->table('posts')->map(sub { |
2193
|
|
|
|
|
|
|
my $post = shift; |
2194
|
|
|
|
|
|
|
return { |
2195
|
|
|
|
|
|
|
title => $post->attr('title'), |
2196
|
|
|
|
|
|
|
author => $post->attr('author')->default('Anonymous') |
2197
|
|
|
|
|
|
|
}; |
2198
|
|
|
|
|
|
|
})->run |
2199
|
|
|
|
|
|
|
|
2200
|
|
|
|
|
|
|
Handle non-existence errors. Tries to evaluate and return its first argument. |
2201
|
|
|
|
|
|
|
If an error related to the absence of a value is thrown in the process, or if |
2202
|
|
|
|
|
|
|
its first argument returns C, returns its second argument. |
2203
|
|
|
|
|
|
|
(Alternatively, the second argument may be a function which will be called with |
2204
|
|
|
|
|
|
|
either the text of the non-existence error or C.) |
2205
|
|
|
|
|
|
|
|
2206
|
|
|
|
|
|
|
=head2 coerce_to |
2207
|
|
|
|
|
|
|
|
2208
|
|
|
|
|
|
|
r->table('posts')->map(sub { |
2209
|
|
|
|
|
|
|
my $post = shift; |
2210
|
|
|
|
|
|
|
return $post->merge({ |
2211
|
|
|
|
|
|
|
'comments' => r->table('comments')->get_all( |
2212
|
|
|
|
|
|
|
$post->attr('id'), { index => 'post_id' })->coerce_to('array') |
2213
|
|
|
|
|
|
|
}); |
2214
|
|
|
|
|
|
|
)->run |
2215
|
|
|
|
|
|
|
|
2216
|
|
|
|
|
|
|
Convert a value of one type into another. |
2217
|
|
|
|
|
|
|
|
2218
|
|
|
|
|
|
|
=head2 type_of |
2219
|
|
|
|
|
|
|
|
2220
|
|
|
|
|
|
|
r->expr('foo')->type_of->run; |
2221
|
|
|
|
|
|
|
|
2222
|
|
|
|
|
|
|
Gets the type of a value. |
2223
|
|
|
|
|
|
|
|
2224
|
|
|
|
|
|
|
=head2 info |
2225
|
|
|
|
|
|
|
|
2226
|
|
|
|
|
|
|
r->table('marvel')->info->run; |
2227
|
|
|
|
|
|
|
|
2228
|
|
|
|
|
|
|
Get information about a ReQL value. |
2229
|
|
|
|
|
|
|
|
2230
|
|
|
|
|
|
|
=head2 fill |
2231
|
|
|
|
|
|
|
|
2232
|
|
|
|
|
|
|
r->table('geo')->insert( |
2233
|
|
|
|
|
|
|
{ |
2234
|
|
|
|
|
|
|
'id' => 201, |
2235
|
|
|
|
|
|
|
'rectangle' => r->line( |
2236
|
|
|
|
|
|
|
[ -122.423246, 37.779388 ], |
2237
|
|
|
|
|
|
|
[ -122.423246, 37.329898 ], |
2238
|
|
|
|
|
|
|
[ -121.886420, 37.329898 ], |
2239
|
|
|
|
|
|
|
[ -121.886420, 37.779388 ] |
2240
|
|
|
|
|
|
|
) |
2241
|
|
|
|
|
|
|
} |
2242
|
|
|
|
|
|
|
)->run; |
2243
|
|
|
|
|
|
|
|
2244
|
|
|
|
|
|
|
r->table('geo')->get(201) |
2245
|
|
|
|
|
|
|
->update( { 'rectangle' => r->row->bracket('rectangle')->fill }, |
2246
|
|
|
|
|
|
|
{ non_atomic => r->true } )->run; |
2247
|
|
|
|
|
|
|
|
2248
|
|
|
|
|
|
|
|
2249
|
|
|
|
|
|
|
Convert a C object into a C object. If the last point does not |
2250
|
|
|
|
|
|
|
specify the same coordinates as the first point, C will close the |
2251
|
|
|
|
|
|
|
polygon by connecting them. |
2252
|
|
|
|
|
|
|
|
2253
|
|
|
|
|
|
|
=head2 includes |
2254
|
|
|
|
|
|
|
|
2255
|
|
|
|
|
|
|
r->circle( r->point( -117.220406, 32.719464 ), 2000 ) |
2256
|
|
|
|
|
|
|
->includes( r->point( -117.206201, 32.725186 ) )->run($conn); |
2257
|
|
|
|
|
|
|
|
2258
|
|
|
|
|
|
|
Tests whether a geometry object is completely contained within another. When |
2259
|
|
|
|
|
|
|
applied to a sequence of geometry objects, L acts as a L, |
2260
|
|
|
|
|
|
|
returning a sequence of objects from the sequence that include the argument. |
2261
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
=head2 intersects |
2263
|
|
|
|
|
|
|
|
2264
|
|
|
|
|
|
|
r->circle( r->point( -117.220406, 32.719464 ), 2000 ) |
2265
|
|
|
|
|
|
|
->intersects( r->point( -117.206201, 32.725186 ) )->run($conn); |
2266
|
|
|
|
|
|
|
|
2267
|
|
|
|
|
|
|
Tests whether two geometry objects intersect with one another. When applied |
2268
|
|
|
|
|
|
|
to a sequence of geometry objects, L acts as a L, |
2269
|
|
|
|
|
|
|
returning a sequence of objects from the sequence that intersect with the |
2270
|
|
|
|
|
|
|
argument. |
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
=head2 polygon_sub |
2273
|
|
|
|
|
|
|
|
2274
|
|
|
|
|
|
|
r->polygon( |
2275
|
|
|
|
|
|
|
[ -122.4, 37.7 ], |
2276
|
|
|
|
|
|
|
[ -122.4, 37.3 ], |
2277
|
|
|
|
|
|
|
[ -121.8, 37.3 ], |
2278
|
|
|
|
|
|
|
[ -121.8, 37.7 ] |
2279
|
|
|
|
|
|
|
)->polygon_sub( |
2280
|
|
|
|
|
|
|
r->polygon( |
2281
|
|
|
|
|
|
|
[ -122.3, 37.4 ], |
2282
|
|
|
|
|
|
|
[ -122.3, 37.6 ], |
2283
|
|
|
|
|
|
|
[ -122.0, 37.6 ], |
2284
|
|
|
|
|
|
|
[ -122.0, 37.4 ] |
2285
|
|
|
|
|
|
|
) |
2286
|
|
|
|
|
|
|
)->run($conn); |
2287
|
|
|
|
|
|
|
|
2288
|
|
|
|
|
|
|
Use C to "punch out" a hole in C. C must be |
2289
|
|
|
|
|
|
|
completely contained within C and must have no holes itself (it must |
2290
|
|
|
|
|
|
|
not be the output of L itself). |
2291
|
|
|
|
|
|
|
|
2292
|
|
|
|
|
|
|
=head2 to_geojson |
2293
|
|
|
|
|
|
|
|
2294
|
|
|
|
|
|
|
r->table('geo')->get('sfo')->bracket('location')->to_geojson->run; |
2295
|
|
|
|
|
|
|
|
2296
|
|
|
|
|
|
|
Convert a ReQL geometry object to a L object. |
2297
|
|
|
|
|
|
|
|
2298
|
|
|
|
|
|
|
=head2 round |
2299
|
|
|
|
|
|
|
|
2300
|
|
|
|
|
|
|
r->expr(-12.567)->round->run($conn); |
2301
|
|
|
|
|
|
|
|
2302
|
|
|
|
|
|
|
Rounds the given value to the nearest whole integer. For example, values of |
2303
|
|
|
|
|
|
|
1.0 up to but not including 1.5 will return 1.0, similar to L; values |
2304
|
|
|
|
|
|
|
of 1.5 up to 2.0 will return 2.0, similar to L. |
2305
|
|
|
|
|
|
|
|
2306
|
|
|
|
|
|
|
=head2 ceil |
2307
|
|
|
|
|
|
|
|
2308
|
|
|
|
|
|
|
r->expr(-12.567)->ceil->run($conn); |
2309
|
|
|
|
|
|
|
|
2310
|
|
|
|
|
|
|
Rounds the given value up, returning the smallest integer value greater than |
2311
|
|
|
|
|
|
|
or equal to the given value (the value's ceiling). |
2312
|
|
|
|
|
|
|
|
2313
|
|
|
|
|
|
|
=head2 floor |
2314
|
|
|
|
|
|
|
|
2315
|
|
|
|
|
|
|
r->expr(-12.567)->floor->run($conn); |
2316
|
|
|
|
|
|
|
|
2317
|
|
|
|
|
|
|
Rounds the given value down, returning the largest integer value less than or |
2318
|
|
|
|
|
|
|
equal to the given value (the value's floor). |
2319
|
|
|
|
|
|
|
|
2320
|
|
|
|
|
|
|
=head1 SEE ALSO |
2321
|
|
|
|
|
|
|
|
2322
|
|
|
|
|
|
|
L, L |
2323
|
|
|
|
|
|
|
|
2324
|
|
|
|
|
|
|
=cut |