NAME

Neo4j::Driver::Type::Node - Describes a node from a Neo4j graph

VERSION

version 0.35

SYNOPSIS

 $query = 'MATCH (m:Movie) RETURN m LIMIT 1';
 $node = $driver->session->run($query)->single->get('m');
 
 say 'Movie id ', $node->element_id(), ' :';
 say '   ', $node->get('name'), ' / ', $node->get('year');
 say '   Labels: ', join ', ', $node->labels;

DESCRIPTION

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

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

METHODS

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

element_id

 $string = $node->element_id;

Return an ID for this node 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 nodes, attaching an explicit 'id' property is a better choice.

get

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

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

id

 $number = $node->id;

Return a legacy numeric ID for this node 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 will be issued by this method in a future version of this driver.

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

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

labels

 @labels = $node->labels;

See "labels" in Neo4j::Types::Node.

properties

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

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

EXPERIMENTAL FEATURES

Neo4j::Driver::Type::Node implements the following experimental features. These are subject to unannounced modification or removal in future versions. Expect your code to break if you depend upon these features.

Calling in scalar context

 $count = $node->labels;

The labels() method returns the number of labels if called in scalar context.

Until version 0.25, it died instead.

BUGS

The value of properties named _meta, _node, or _labels may not be returned correctly.

When using HTTP JSON, the labels of nodes that are returned as part of a Neo4j::Driver::Type::Path are 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.