The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

VERSION

version 0.19

SYNOPSIS

 $query = 'MATCH (m:Movie) RETURN m LIMIT 1';
 $node = $driver->session->run($query)->single->get('m');
 
 say 'Movie # ', $node->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 IDs.

METHODS

Neo4j::Driver::Type::Node implements the following methods.

get

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

Retrieve the value of this node's property with the given key. If no such key exists, return undef.

id

 $id = $node->id;

Return a unique ID for this node.

In the Neo4j Driver API, entity IDs are only guaranteed to remain stable for the duration of the current session. Although in practice server versions at least up to and including Neo4j 3.5 may appear to use persistent IDs, your code should not depend upon that.

A node with the ID 0 may exist. Nodes and relationships do not share the same ID space.

labels

 @labels = $node->labels;

Return all labels of this node.

properties

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

Return all properties of this node as a hash reference.

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

 $labels = $node->labels;  # fails

The labels() method dies if called in scalar context.

Deletion indicator

 $node_exists = ! $node->deleted;

In some circumstances, Cypher statements using DELETE may still RETURN nodes that were deleted. To help avoid confusion in such cases, the server sometimes reports whether or not a node was deleted.

This method is experimental because that information is not reliably available. In particular, there is a known issue with the Neo4j server (#12306), and old Neo4j versions may not report it at all. If unavailable, undef will be returned by this method.

BUGS

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

When using HTTP, 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>

COPYRIGHT AND LICENSE

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

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)