Neo4j::Driver::Record - Container for Cypher result values
version 0.31
use Neo4j::Driver; $session = Neo4j::Driver->new->basic_auth(...)->session; $query = 'MATCH (m:Movie) RETURN m.name, m.year'; $records = $session->run($query)->list; foreach $record ( @$records ) { say $record->get('m.name'); } $query .= ' ORDER BY m.year LIMIT 1'; $record = $session->run($query)->single; say 'Year of oldest movie: ', $record->get(1);
Container for Cypher result values. Records are returned from Cypher statement execution, contained within a Result. A record is a form of ordered map and, as such, contained values can be accessed by either positional index or textual key.
To obtain a record, call "fetch" in Neo4j::Driver::Result.
Neo4j::Driver::Record implements the following methods.
$value1 = $record->get('field_key'); $value2 = $record->get(2);
Get a value from this record, either by field key or by zero-based index.
When called without parameters, get() will return the first field. If there is more than a single field, a warning in the category ambiguous will be issued.
get()
ambiguous
$value = $session->run('RETURN "It works!"')->single->get; $value = $session->run('RETURN "warning", "ambiguous"')->single->get;
When retrieving values from records, Neo4j types are converted to Perl types as shown in the following table.
Neo4j type resulting Perl type ---------- ------------------- Number scalar String scalar Boolean JSON::PP::true or JSON::PP::false null undef Node Neo4j::Types::Node Relationship Neo4j::Types::Relationship Path Neo4j::Types::Path List array reference Map hash reference
Boolean values are returned in a type that is trackable such that their being boolean is preserved in case they are sent back to Neo4j as a query parameter. They are currently provided as JSON::PP::Boolean, but you can use !! to force-convert to a plain scalar Perl distinguished boolean value if necessary. Future versions of this driver may switch to always provide distinguished booleans.
!!
Neo4j types are currently implemented by the following packages:
Neo4j::Types::Node is implemented by Neo4j::Driver::Type::Node.
Neo4j::Types::Relationship is implemented by Neo4j::Driver::Type::Relationship.
Neo4j::Types::Path is implemented by Neo4j::Driver::Type::Path.
In a future version of this driver, these types will be implemented by other packages, but they will continue to inherit from Neo4j::Types and have that interface.
$hashref = $record->data; $value = $hashref->{field_key};
Return the keys and values of this record as a hash reference.
Neo4j::Driver
Neo4j::Driver::Type::Node, Neo4j::Driver::Type::Relationship, Neo4j::Driver::Type::Path
Equivalent documentation for the official Neo4j drivers: Record (Java), Record (JavaScript), IRecord (.NET)
Arne Johannessen <ajnn@cpan.org>
This software is Copyright (c) 2016-2022 by Arne Johannessen.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Neo4j::Driver, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Neo4j::Driver
CPAN shell
perl -MCPAN -e shell install Neo4j::Driver
For more information on module installation, please visit the detailed CPAN module installation guide.