node

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 2 Imported by: 0

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

Storage is the interface for database operations.

Functions

func Connected

func Connected(node1, node2 *Node, relType string) bool

Connected checks if two nodes are connected.

Example:

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

func Degree

func Degree(node *Node, relType string) int

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

Example:

apoc.node.degree(node) => 5

func DegreeIn

func DegreeIn(node *Node, relType string) int

DegreeIn returns the in-degree of a node.

Example:

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

func DegreeOut

func DegreeOut(node *Node, relType string) int

DegreeOut returns the out-degree of a node.

Example:

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

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 IsDense

func IsDense(node *Node, threshold int) bool

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

Example:

apoc.node.isDense(node) => true

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 RelationshipExists

func RelationshipExists(node *Node, relPattern string) bool

RelationshipExists checks if a relationship exists.

Example:

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

func RelationshipTypes

func RelationshipTypes(node *Node) []string

RelationshipTypes returns all relationship types of a node.

Example:

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

func RelationshipTypesIn

func RelationshipTypesIn(node *Node) []string

RelationshipTypesIn returns incoming relationship types.

Example:

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

func RelationshipTypesOut

func RelationshipTypesOut(node *Node) []string

RelationshipTypesOut returns outgoing relationship types.

Example:

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

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 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 Neighbors

func Neighbors(node *Node, relType string) []*Node

Neighbors returns neighboring nodes.

Example:

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

func NeighborsIn

func NeighborsIn(node *Node, relType string) []*Node

NeighborsIn returns incoming neighbors.

Example:

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

func NeighborsOut

func NeighborsOut(node *Node, relType string) []*Node

NeighborsOut returns outgoing neighbors.

Example:

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

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.

func Relationships

func Relationships(node *Node, relType string) []*Relationship

Relationships returns all relationships of a node.

Example:

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

func RelationshipsIn

func RelationshipsIn(node *Node, relType string) []*Relationship

RelationshipsIn returns incoming relationships.

Example:

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

func RelationshipsOut

func RelationshipsOut(node *Node, relType string) []*Relationship

RelationshipsOut returns outgoing relationships.

Example:

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

Jump to

Keyboard shortcuts

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