Hideaki Ohno > ArangoDB > ArangoDB::Statement

Download:
ArangoDB-0.08.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

ArangoDB::Statement - An ArangoDB AQL handler

SYNOPSIS ^

    use ArangoDB;
    
    my $db = ArangoDB->new(
        host => 'localhost',
        port => 8529,
    );
  
    my $sth = $db->query('FOR u IN users FILTER u.active == true RETURN u');
    my $cursor = $sth->execute({ 
        do_count => 1, 
        batch_size => 10,
    });
    while( my $doc = $cursor->next() ){
        # do something
    }
  
    # Use bind variable
    my $documents = $db->query(
        'FOR u IN users FILTER u.age >= @age SORT u.name ASC RETURN u'
    )->bind( age => 18 )->execute()->all;

DESCRIPTION ^

An AQL(ArangoDB Query Language) statement handler.

METHODS ^

new($conn,$query)

Constructor.

$conn

Instance of ArangoDB::Connection.

$query

AQL statement.

execute($options)

Execute AQL query and returns cursor(instance of ArangoDB::Cursor).

$options is query options.The attributes of $options are:

batch_size

Maximum number of result documents to be transferred from the server to the client in one roundtrip (optional).

do_count

Boolean flag that indicates whether the number of documents found should be returned as "count" attribute in the result set (optional).

parse()

Parse a query string without executing.

Return ARRAY reference of bind variable names.

explain()

Get execution plan of query.

Returns ARRAY reference.

bind_vars($name)

Returns bind variable based on $name.

If $name does not passed, returns all bind variables as HASH reference.

bind($vars)

bind($key => $value)

Set bind variable(s).

$vars

HASH reference that set of key/value pairs.

$key

Bind variable name.

$value

Bind variable value.

Returns instance of ArangoDB::Statement.You can use method chain:

    my $documents = $db->query(
        'FOR u IN users FILTER u.type == @type && u.age >= @age SORT u.name ASC RETURN u'
    )->bind({
        type => 1, 
        age  => 19 
    })->execute->all;

AUTHOR ^

Hideaki Ohno <hide.o.j55 {at} gmail.com>

syntax highlighting: