Neo4j-Driver
view release on metacpan or search on metacpan
lib/Neo4j/Driver.pm view on Meta::CPAN
$query = <<~END;
MATCH (someone :Person)-[:KNOWS]->(friend)
WHERE someone.name = \$name
RETURN friend.name
END
@records = $session->execute_read( sub ($tx) {
$tx->run($query, { name => 'Alice' })->list;
});
foreach my $record ( @records ) {
say $record->get('friend.name');
}
=head1 DESCRIPTION
This software is a community driver for the
L<Neo4j|https://neo4j.com/> graph database server.
It is designed to follow the Neo4j Driver API, allowing
clients to interact with a Neo4j server using the same
classes and method calls as the official Neo4j drivers do.
This extends the uniformity across languages, which is a
stated goal of the Neo4j Driver API, to Perl.
This driver targets the Neo4j community edition,
version 2.x, 3.x, 4.x, and 5.x. Other Neo4j editions are
only supported as far as practical, but patches targeting
them are welcome.
Two different network protocols exist for connecting to Neo4j.
By default, Neo4j servers offer both, but this can be changed
in F<neo4j.conf> for each server; see
L<"Configure connectors" in the Neo4j Operations Manual|https://neo4j.com/docs/operations-manual/current/configuration/connectors/>.
=over
=item Bolt
Bolt is a Neo4j proprietary, binary protocol, available with
S<Neo4j 3.5> and newer. Bolt communication may be encrypted or
unencrypted. Because Bolt is faster than HTTP, it is generally
the recommended protocol. However, Perl support for it tends
to lag behind after major updates to Neo4j.
This driver supports Bolt, but doesn't bundle the necessary XS
packages. You will need to install S<L<Neo4j::Bolt> 0.4201> or
later separately to enable Bolt for this driver.
=item HTTP / HTTPS
Support for HTTP is built into this driver, so it is always
available. HTTP is still fast enough for many use cases and
works even in a "Pure Perl" environment. It may also be
quicker than Bolt to add support for future changes in Neo4j.
HTTP connections will use B<Jolt> (JSON Bolt) when offered by the server.
For older Neo4j servers (before S<version 4.2>), the driver
will automatically fall back to slower REST-style JSON.
The driver also supports encrypted communication using HTTPS,
but doesn't bundle the necessary packages. You will need to
install L<IO::Socket::SSL> separately to enable HTTPS.
=back
The protocol is automatically chosen based on the URI scheme.
See L<Neo4j::Driver::Config/"uri"> for details.
Version 1 of Neo4j::Driver is targeting Perl v5.20 and later.
Patches will be accepted to address issues with Perl versions
as old as v5.16.3 for as long as practical.
=head1 METHODS
L<Neo4j::Driver> implements the following methods.
=head2 basic_auth
$driver->basic_auth('neo4j', 'password');
Set basic auth credentials with a given user and password. This
method returns the modified L<Neo4j::Driver> object, so that method
chaining is possible.
$session = $driver->basic_auth('neo4j', 'password')->session;
=head2 config
$driver->config({ option1 => 'foo', option2 => 'bar' });
Sets the specified configuration options on a L<Neo4j::Driver>
object. The options may be given as a hash or as a hash reference.
This method returns the modified object, so that method chaining
is possible.
$session = $driver->config(timeout => 60)->session;
See L<Neo4j::Driver::Config> for a list of supported options.
Setting configuration options on a driver is only allowed before
creating the driver's first session.
Calling this method with just a single string parameter will return
the current value of the config option named by the parameter.
$timeout = $driver->config('timeout');
=head2 new
$driver = Neo4j::Driver->new({ uri => 'http://localhost' });
Construct a new L<Neo4j::Driver> object. This object holds the
details required to establish connections with a Neo4j database,
including server URIs, credentials and other configuration.
The C<new()> method accepts one or more configuration options given
as a hash reference. See L<Neo4j::Driver::Config> for a
list of supported options. Alternatively, instead of the hash
reference, the Neo4j server URI may be given as a scalar string.
$driver = Neo4j::Driver->new('bolt://localhost');
If C<new()> is called with no arguments, a default configuration
( run in 1.337 second using v1.01-cache-2.11-cpan-39bf76dae61 )