NAME

Neo4j::Types::Node - Represents a Neo4j node / graph vertex

VERSION

version 2.00

SYNOPSIS

@labels  = $node->labels;

$node_id = $node->element_id;  # Neo4j 5 and newer
$node_id = $node->id;          # Neo4j 4 and older

$property1  = $node->get('property1');
$property2  = $node->get('property2');
%properties = %{ $node->properties };

DESCRIPTION

Describes a node from a Neo4j graph. A node may be created by executing a Cypher statement against a Neo4j database server. Its description contains the node's properties as well as certain meta data, all accessible by methods that this class provides.

Neo4j::Types::Node objects are typically 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::Types::Node objects may be created. Refer to the documentation of the Perl module you use to fetch nodes from the Neo4j database for information about how that particular module handles this aspect.

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 than using the Neo4j node ID or element ID.

METHODS

Neo4j::Types::Node implements the following methods.

element_id

$string = $node->element_id;

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

The element ID string was introduced with Neo4j 5. When it is unavailable, for example because this module is used with Neo4j server version 4 or earlier, this method will issue a warning in the Neo4j::Types category and return the legacy numeric ID instead; see id().

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

$number = $node->id;

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

On Neo4j 5 and above, numeric IDs are deprecated. They may become unavailable in future. Use element_id() instead.

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;

Return all labels of this node.

In scalar context, return the number of labels on this node.

$count = scalar $node->labels;

properties

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

Return all properties of this node as a hash reference.

This hash reference should be used for read access only. The result of attempts to change this hash is not defined by Neo4j::Types.

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) 2021-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.