| 1 | package ArangoDB2::Query; | ||||||||||
| 2 | |||||||||||
| 3 | 22 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 22 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 22 | ▶ | use base qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | ArangoDB2::Base | ||||||||||
| 8 | 22 | ); | |||||||||
| 9 | |||||||||||
| 10 | 22 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 22 | ▶ | use JSON::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 22 | ▶ | use ArangoDB2::Cursor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 22 | my $JSON = JSON::XS->new->utf8; | |||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | # new | ||||||||||
| 20 | # | ||||||||||
| 21 | # create new instance | ||||||||||
| 22 | sub new | ||||||||||
| 23 | 2 | ▶ | { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | 2 | my($class, $arango, $database, $query) = @_; | |||||||||
| 25 | |||||||||||
| 26 | 2 | my $self = $class->SUPER::new($arango, $database); | |||||||||
| 27 | 2 | $self->query($query); | |||||||||
| 28 | |||||||||||
| 29 | 2 | return $self; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | # batchSize | ||||||||||
| 33 | # | ||||||||||
| 34 | # maximum number of result documents | ||||||||||
| 35 | 0 | ▶ | sub batchSize { shift->_get_set('batchSize', @_) } | ||||||||
|
Subroutine
batchSize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | |||||||||||
| 37 | # count | ||||||||||
| 38 | # | ||||||||||
| 39 | # boolean flag that indicates whether the number of documents in the | ||||||||||
| 40 | # result set should be returned. | ||||||||||
| 41 | 0 | ▶ | sub count { shift->_get_set_bool('count', @_) } | ||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | |||||||||||
| 43 | # execute | ||||||||||
| 44 | # | ||||||||||
| 45 | # POST /_api/cursor | ||||||||||
| 46 | sub execute | ||||||||||
| 47 | 0 | ▶ | { | ||||||||
|
Subroutine
execute: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 48 | 0 | my($self, $bind, $args) = @_; | |||||||||
| 49 | # process args | ||||||||||
| 50 | 0 | $args = $self->_build_args($args, [qw( | |||||||||
| 51 | batchSize fullCount count query ttl | ||||||||||
| 52 | )]); | ||||||||||
| 53 | # fullCount is an exception that belongs under options | ||||||||||
| 54 | $args->{options}->{fullCount} = delete $args->{fullCount} | ||||||||||
| 55 | 0 | ▶ | if exists $args->{fullCount}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | # set bindVars if bind is passed | ||||||||||
| 57 | 0 | ▶ | $args->{bindVars} = $bind | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | if defined $bind; | ||||||||||
| 59 | # make request | ||||||||||
| 60 | 0 | ▶ | my $res = $self->arango->http->post( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | $self->api_path('cursor'), | ||||||||||
| 62 | undef, | ||||||||||
| 63 | $JSON->encode($args), | ||||||||||
| 64 | ) or return; | ||||||||||
| 65 | |||||||||||
| 66 | 0 | return ArangoDB2::Cursor->new($self->arango, $self->database, $res); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | # fullCount | ||||||||||
| 70 | # | ||||||||||
| 71 | # include result count greater than LIMIT | ||||||||||
| 72 | # | ||||||||||
| 73 | # default false | ||||||||||
| 74 | 0 | ▶ | sub fullCount { shift->_get_set_bool('fullCount', @_) } | ||||||||
|
Subroutine
fullCount: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 75 | |||||||||||
| 76 | # explain | ||||||||||
| 77 | # | ||||||||||
| 78 | # POST /_api/explain | ||||||||||
| 79 | sub explain | ||||||||||
| 80 | 0 | ▶ | { | ||||||||
|
Subroutine
explain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 81 | 0 | my($self) = @_; | |||||||||
| 82 | |||||||||||
| 83 | 0 | return $self->arango->http->post( | |||||||||
| 84 | $self->api_path('explain'), | ||||||||||
| 85 | undef, | ||||||||||
| 86 | $JSON->encode({query => $self->query}), | ||||||||||
| 87 | ); | ||||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | # parse | ||||||||||
| 91 | # | ||||||||||
| 92 | # POST /_api/query | ||||||||||
| 93 | sub parse | ||||||||||
| 94 | 0 | ▶ | { | ||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 95 | 0 | my($self) = @_; | |||||||||
| 96 | |||||||||||
| 97 | 0 | return $self->arango->http->post( | |||||||||
| 98 | $self->api_path('query'), | ||||||||||
| 99 | undef, | ||||||||||
| 100 | $JSON->encode({query => $self->query}), | ||||||||||
| 101 | ); | ||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | # query | ||||||||||
| 105 | # | ||||||||||
| 106 | # AQL query | ||||||||||
| 107 | 2 | ▶ | sub query { shift->_get_set('query', @_) } | ||||||||
|
Subroutine
query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 108 | |||||||||||
| 109 | # ttl | ||||||||||
| 110 | # | ||||||||||
| 111 | # an optional time-to-live for the cursor (in seconds) | ||||||||||
| 112 | 0 | ▶ | sub ttl { shift->_get_set('ttl', @_) } | ||||||||
|
Subroutine
ttl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 113 | |||||||||||
| 114 | 22 | 1; | |||||||||
| 115 | |||||||||||
| 116 | __END__ | ||||||||||