REST::Neo4p::Query - Execute Neo4j Cypher queries
REST::Neo4p->connect('http:/127.0.0.1:7474'); $query = REST::Neo4p::Query->new('START n=node(0) RETURN n'); $query->execute; $node = $query->fetch->[0]; $node->relate_to($other_node, 'link');
REST::Neo4p::Query encapsulates Neo4j Cypher language queries, executing them via REST::Neo4p::Agent and returning an iterator over the rows, in the spirit of DBI.
REST::Neo4p::Query
REST::Neo4p::Agent
$stmt = 'START n=node({node_id}) RETURN n'; $query = REST::Neo4p::Query->new($stmt,{node_id => 1});
Create a new query object. First argument is the Cypher query (required). Second argument is a hashref of parameters (optional).
$numrows = $query->execute;
Execute the query on the server.
$query = REST::Neo4p::Query->new('START n=node(0) RETURN n, n.name'); $query->execute; while ($row = $query->fetch) { print 'It works!" if ($row->[0]->get_property('name') == $row->[1]); }
Fetch the next row of returned data (as an arrayref). Nodes are returned as REST::Neo4p::Node objects, relationships are returned as REST::Neo4p::Relationship objects, scalars are returned as-is.
$query->execute; if ($query->err) { printf "status code: %d\n", $query->err; printf "error message: %s\n", $query->errstr; }
Returns the HTTP error code and Neo4j server error message if an error was encountered on execution. Set $query->{RaiseError} to die immediately (e.g., to catch the exception in an eval block).
$query->{RaiseError}
eval
REST::Neo4p, REST::Neo4p::Agent.
Mark A. Jensen CPAN ID: MAJENSEN majensen -at- cpan -dot- org
Copyright (c) 2012 Mark A. Jensen. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install REST::Neo4p, copy and paste the appropriate command in to your terminal.
cpanm
cpanm REST::Neo4p
CPAN shell
perl -MCPAN -e shell install REST::Neo4p
For more information on module installation, please visit the detailed CPAN module installation guide.