The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Neo4j::Driver::Type::Relationship - Describes a relationship from a Neo4j graph

VERSION

version 0.39

SYNOPSIS

 $q = "MATCH (a:Person)-[k:KNOWS]->(b:Person) RETURN k";
 $rel = $driver->session->run($q)->list->[0]->get('k');
 
 print 'Person id ', $rel->start_element_id;
 print ' ', $rel->type;
 print ' person id ', $rel->end_element_id;
 print ' since ', $rel->properties->{since};

DESCRIPTION

Describes a relationship from a Neo4j graph. A relationship may be a part of records returned from Cypher statement execution. Its description contains the relationship's properties as well as certain meta data, all accessible by methods that this class provides.

Neo4j::Driver::Type::Relationship objects are not in a one-to-one relation with relationships in a Neo4j graph. If the same Neo4j relationship is fetched multiple times, then multiple distinct Neo4j::Driver::Type::Relationship objects will be created by the driver. If your intention is to verify that two Neo4j::Driver::Type::Relationship objects in Perl describe the same node in the Neo4j database, you need to compare their element IDs.

METHODS

Neo4j::Driver::Type::Relationship inherits all methods from Neo4j::Types::Relationship.

element_id

 $string = $relationship->element_id;

Return an ID for this relationship that is unique within a particular context, for example the current transaction.

This method provides the new element ID string introduced by Neo4j 5. If the element ID is unavailable, for example with older Neo4j versions or with a Neo4j::Bolt version that hasn't yet been updated for Neo4j 5, this method provides the legacy numeric ID instead. Note that a numeric ID cannot successfully be used with elementId() in Cypher expressions.

Neo4j element IDs are not designed to be persistent. As such, if you want a public identity to use for your relationships, attaching an explicit 'id' property is a better choice.

get

 $value = $relationship->get('property_key');

See "get" in Neo4j::Types::Relationship.

id

 $number = $relationship->id;

Return a legacy numeric ID for this relationship that is unique within a particular context, for example the current transaction.

Neo4j 5 has deprecated numeric IDs. They will likely become unavailable in future Neo4j versions. This method will try to auto-generate a numeric ID from the new element ID value (or return undef if that fails). A deprecation warning is issued by this method if the element ID is available.

Neo4j relationship IDs are not designed to be persistent. As such, if you want a public identity to use for your relationships, attaching an explicit 'id' property is a better choice.

Legacy IDs are always integer numbers. A relationship with the ID 0 may exist. Nodes and relationships do not share the same ID space.

properties

 $hashref = $relationship->properties;
 $value = $hashref->{property_key};

See "properties" in Neo4j::Types::Relationship.

start_element_id

 $string = $relationship->start_element_id;

Return an element ID for the node where this relationship starts.

This method provides the new element ID string introduced by Neo4j 5. If the element ID is unavailable, for example with older Neo4j versions or with a Neo4j::Bolt version that hasn't yet been updated for Neo4j 5, this method provides the legacy numeric ID instead.

start_id

 $number = $relationship->start_id;

Return a numeric ID for the node where this relationship starts.

Neo4j 5 has deprecated numeric IDs. They will likely become unavailable in future Neo4j versions. This method will try to auto-generate a numeric ID from the new element ID value (or return undef if that fails). A deprecation warning is issued by this method if the element ID is available.

end_element_id

 $string = $relationship->end_element_id;

Return an element ID for the node where this relationship ends.

This method provides the new element ID string introduced by Neo4j 5. If the element ID is unavailable, for example with older Neo4j versions or with a Neo4j::Bolt version that hasn't yet been updated for Neo4j 5, this method provides the legacy numeric ID instead.

end_id

 $number = $relationship->end_id;

Return a numeric ID for the node where this relationship ends.

Neo4j 5 has deprecated numeric IDs. They will likely become unavailable in future Neo4j versions. This method will try to auto-generate a numeric ID from the new element ID value (or return undef if that fails). A deprecation warning is issued by this method if the element ID is available.

type

 $type = $relationship->type;

See "type" in Neo4j::Types::Relationship.

BUGS

The value of properties named _meta, _relationship, _start, _end, or _type may not be returned correctly.

When using HTTP JSON, the type of relationships that are returned as part of a Neo4j::Driver::Type::Path is unavailable, because that information is not currently reported by the Neo4j server. undef is returned instead.

SEE ALSO

AUTHOR

Arne Johannessen <ajnn@cpan.org>

If you contact me by email, please make sure you include the word "Perl" in your subject header to help beat the spam filters.

COPYRIGHT AND LICENSE

This software is Copyright (c) 2016-2023 by Arne Johannessen.

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 or (at your option) the same terms as the Perl 5 programming language system itself.