ArangoDB2

 view release on metacpan or  search on metacpan

lib/ArangoDB2/Query.pm  view on Meta::CPAN

package ArangoDB2::Query;

use strict;
use warnings;

use base qw(
    ArangoDB2::Base
);

use Data::Dumper;
use JSON::XS;

use ArangoDB2::Cursor;

my $JSON = JSON::XS->new->utf8;



# new
#
# create new instance
sub new
{
    my($class, $arango, $database, $query) = @_;

    my $self = $class->SUPER::new($arango, $database);
    $self->query($query);

    return $self;
}

# batchSize
#
# maximum number of result documents
sub batchSize { shift->_get_set('batchSize', @_) }

# count
#
# boolean flag that indicates whether the number of documents in the
# result set should be returned.
sub count { shift->_get_set_bool('count', @_) }

# execute
#
# POST /_api/cursor
sub execute
{
    my($self, $bind, $args) = @_;
    # process args
    $args = $self->_build_args($args, [qw(
        batchSize fullCount count query ttl
    )]);
    # fullCount is an exception that belongs under options
    $args->{options}->{fullCount} = delete $args->{fullCount}
        if exists $args->{fullCount};
    # set bindVars if bind is passed
    $args->{bindVars} = $bind
        if defined $bind;
    # make request
    my $res = $self->arango->http->post(
        $self->api_path('cursor'),
        undef,
        $JSON->encode($args),
    ) or return;

    return ArangoDB2::Cursor->new($self->arango, $self->database, $res);
}

# fullCount
#
# include result count greater than LIMIT
#
# default false
sub fullCount { shift->_get_set_bool('fullCount', @_) }



( run in 1.023 second using v1.01-cache-2.11-cpan-39bf76dae61 )