node

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package node provides APOC node operations.

This package implements all apoc.node.* functions for working with nodes in Cypher queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(node1, node2 *Node) map[string]interface{}

Diff compares two nodes and returns differences.

Example:

apoc.node.diff(node1, node2)
=> {added:{...}, removed:{...}, changed:{...}}

func Equals

func Equals(node1, node2 *Node) bool

Equals checks if two nodes are equal.

Example:

apoc.node.equals(node1, node2) => true

func HasLabel

func HasLabel(node *Node, label string) bool

HasLabel checks if a node has a specific label.

Example:

apoc.node.hasLabel(node, 'Person') => true

func HasLabels

func HasLabels(node *Node, labels []string) bool

HasLabels checks if a node has all specified labels.

Example:

apoc.node.hasLabels(node, ['Person', 'Employee']) => true

func ID

func ID(node *Node) int64

ID returns the ID of a node.

Example:

apoc.node.id(node) => 123

func Labels

func Labels(node *Node) []string

Labels returns the labels of a node.

Example:

apoc.node.labels(node) => ['Person', 'Employee']

func Properties

func Properties(node *Node) map[string]interface{}

Properties returns all properties of a node.

Example:

apoc.node.properties(node) => {name:'Alice', age:30}

func Property

func Property(node *Node, key string) interface{}

Property returns a specific property value.

Example:

apoc.node.property(node, 'name') => 'Alice'

func ToMap

func ToMap(node *Node) map[string]interface{}

ToMap converts a node to a map.

Example:

apoc.node.toMap(node) => {id:123, labels:['Person'], properties:{...}}

Types

type Functions

type Functions struct {
	// contains filtered or unexported fields
}

Functions binds this package's storage-dependent helpers to one storage backend. The backend is fixed when the instance is created, so a handler an already-admitted caller holds keeps the backend it was built for.

func New

func New(backend storage.Storage) *Functions

New returns this package's helpers bound to backend. One instance serves one backend; a reconfiguration builds a new instance instead of rebinding this one.

func (*Functions) Connected

func (f *Functions) Connected(ctx context.Context, node1, node2 *Node, relType string) (bool, error)

Connected checks if two nodes are connected.

Example:

apoc.node.connected(node1, node2, 'KNOWS') => true

func (*Functions) Degree

func (f *Functions) Degree(ctx context.Context, node *Node, relType string) (int, error)

Degree returns the degree (number of relationships) of a node.

Example:

apoc.node.degree(node) => 5

func (*Functions) DegreeIn

func (f *Functions) DegreeIn(ctx context.Context, node *Node, relType string) (int, error)

DegreeIn returns the in-degree of a node.

Example:

apoc.node.degree.in(node, 'KNOWS') => 3

func (*Functions) DegreeOut

func (f *Functions) DegreeOut(ctx context.Context, node *Node, relType string) (int, error)

DegreeOut returns the out-degree of a node.

Example:

apoc.node.degree.out(node, 'KNOWS') => 2

func (*Functions) IsDense

func (f *Functions) IsDense(ctx context.Context, node *Node, threshold int) (bool, error)

IsDense checks if a node is dense (many relationships).

Example:

apoc.node.isDense(node) => true

func (*Functions) Neighbors

func (f *Functions) Neighbors(ctx context.Context, node *Node, relType string) ([]*Node, error)

Neighbors returns neighboring nodes.

Example:

apoc.node.neighbors(node, 'KNOWS') => [node1, node2, ...]

func (*Functions) NeighborsIn

func (f *Functions) NeighborsIn(ctx context.Context, node *Node, relType string) ([]*Node, error)

NeighborsIn returns incoming neighbors.

Example:

apoc.node.neighbors.in(node, 'KNOWS') => [node1, node2]

func (*Functions) NeighborsOut

func (f *Functions) NeighborsOut(ctx context.Context, node *Node, relType string) ([]*Node, error)

NeighborsOut returns outgoing neighbors.

Example:

apoc.node.neighbors.out(node, 'KNOWS') => [node1, node2]

func (*Functions) RelationshipExists

func (f *Functions) RelationshipExists(ctx context.Context, node *Node, relPattern string) (bool, error)

RelationshipExists checks if a relationship exists.

Example:

apoc.node.relationshipExists(node, 'KNOWS>') => true

func (*Functions) RelationshipTypes

func (f *Functions) RelationshipTypes(ctx context.Context, node *Node) ([]string, error)

RelationshipTypes returns all relationship types of a node.

Example:

apoc.node.relationshipTypes(node) => ['KNOWS', 'WORKS_AT']

func (*Functions) RelationshipTypesIn

func (f *Functions) RelationshipTypesIn(ctx context.Context, node *Node) ([]string, error)

RelationshipTypesIn returns incoming relationship types.

Example:

apoc.node.relationshipTypes.in(node) => ['KNOWS', 'FOLLOWS']

func (*Functions) RelationshipTypesOut

func (f *Functions) RelationshipTypesOut(ctx context.Context, node *Node) ([]string, error)

RelationshipTypesOut returns outgoing relationship types.

Example:

apoc.node.relationshipTypes.out(node) => ['KNOWS', 'WORKS_AT']

func (*Functions) Relationships

func (f *Functions) Relationships(ctx context.Context, node *Node, relType string) ([]*Relationship, error)

Relationships returns all relationships of a node.

Example:

apoc.node.relationships(node) => [rel1, rel2, ...]

func (*Functions) RelationshipsIn

func (f *Functions) RelationshipsIn(ctx context.Context, node *Node, relType string) ([]*Relationship, error)

RelationshipsIn returns incoming relationships.

Example:

apoc.node.relationships.in(node, 'KNOWS') => [rel1, rel2]

func (*Functions) RelationshipsOut

func (f *Functions) RelationshipsOut(ctx context.Context, node *Node, relType string) ([]*Relationship, error)

RelationshipsOut returns outgoing relationships.

Example:

apoc.node.relationships.out(node, 'KNOWS') => [rel1, rel2]

type Node

type Node = storage.Node

Node represents a graph node.

func AddLabel

func AddLabel(node *Node, label string) *Node

AddLabel adds a label to a node.

Example:

apoc.node.addLabel(node, 'Employee')

func AddLabels

func AddLabels(node *Node, labels []string) *Node

AddLabels adds multiple labels to a node.

Example:

apoc.node.addLabels(node, ['Employee', 'Manager'])

func Clone

func Clone(node *Node) *Node

Clone creates a copy of a node.

Example:

apoc.node.clone(node) => new node with same properties

func FromMap

func FromMap(m map[string]interface{}) *Node

FromMap creates a node from a map.

Example:

apoc.node.fromMap({labels:['Person'], properties:{name:'Alice'}})

func RemoveLabel

func RemoveLabel(node *Node, label string) *Node

RemoveLabel removes a label from a node.

Example:

apoc.node.removeLabel(node, 'Employee')

func RemoveLabels

func RemoveLabels(node *Node, labels []string) *Node

RemoveLabels removes multiple labels from a node.

Example:

apoc.node.removeLabels(node, ['Employee', 'Manager'])

func RemoveProperties

func RemoveProperties(node *Node, keys []string) *Node

RemoveProperties removes multiple properties from a node.

Example:

apoc.node.removeProperties(node, ['age', 'city'])

func RemoveProperty

func RemoveProperty(node *Node, key string) *Node

RemoveProperty removes a property from a node.

Example:

apoc.node.removeProperty(node, 'age')

func SetProperties

func SetProperties(node *Node, props map[string]interface{}) *Node

SetProperties sets multiple properties on a node.

Example:

apoc.node.setProperties(node, {age:31, city:'NYC'})

func SetProperty

func SetProperty(node *Node, key string, value interface{}) *Node

SetProperty sets a property on a node.

Example:

apoc.node.setProperty(node, 'age', 31)

type Relationship

type Relationship = storage.Relationship

Relationship represents a graph relationship.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL