ArangoDB2
view release on metacpan or search on metacpan
lib/ArangoDB2/Cursor.pm view on Meta::CPAN
package ArangoDB2::Cursor;
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
# new
#
# create new instance
sub new
{
my($class, $arango, $database, $data) = @_;
my $self = $class->SUPER::new($arango, $database);
$self->{data} = $data;
return $self;
}
# all
#
# get all results
sub all
{
my($self) = @_;
# need data
return unless $self->data;
my $result = $self->data->{result};
# add any additional batches to the initial result
while ($self->get) {
push(@$result, @{$self->data->{result}});
}
return $result;
}
# count
#
# get count of results
sub count
{
my($self) = @_;
return $self->data && $self->data->{count};
}
# delete
#
# DELETE /_api/cursor/{cursor-identifier}
sub delete
{
my($self) = @_;
# need data
return unless $self->data
and $self->data->{hasMore};
return $self->arango->http->delete(
$self->api_path('cursor', $self->data->{id}),
);
}
# each
#
# iterate over results calling callback function
sub each
{
my($self, $func) = @_;
# require code ref
die "Invalid Args"
unless ref $func eq 'CODE';
# need data
return unless $self->data;
( run in 2.084 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )