Documentation
¶
Overview ¶
Package node provides APOC node operations.
This package implements all apoc.node.* functions for working with nodes in Cypher queries.
Index ¶
- func Diff(node1, node2 *Node) map[string]interface{}
- func Equals(node1, node2 *Node) bool
- func HasLabel(node *Node, label string) bool
- func HasLabels(node *Node, labels []string) bool
- func ID(node *Node) int64
- func Labels(node *Node) []string
- func Properties(node *Node) map[string]interface{}
- func Property(node *Node, key string) interface{}
- func ToMap(node *Node) map[string]interface{}
- type Functions
- func (f *Functions) Connected(ctx context.Context, node1, node2 *Node, relType string) (bool, error)
- func (f *Functions) Degree(ctx context.Context, node *Node, relType string) (int, error)
- func (f *Functions) DegreeIn(ctx context.Context, node *Node, relType string) (int, error)
- func (f *Functions) DegreeOut(ctx context.Context, node *Node, relType string) (int, error)
- func (f *Functions) IsDense(ctx context.Context, node *Node, threshold int) (bool, error)
- func (f *Functions) Neighbors(ctx context.Context, node *Node, relType string) ([]*Node, error)
- func (f *Functions) NeighborsIn(ctx context.Context, node *Node, relType string) ([]*Node, error)
- func (f *Functions) NeighborsOut(ctx context.Context, node *Node, relType string) ([]*Node, error)
- func (f *Functions) RelationshipExists(ctx context.Context, node *Node, relPattern string) (bool, error)
- func (f *Functions) RelationshipTypes(ctx context.Context, node *Node) ([]string, error)
- func (f *Functions) RelationshipTypesIn(ctx context.Context, node *Node) ([]string, error)
- func (f *Functions) RelationshipTypesOut(ctx context.Context, node *Node) ([]string, error)
- func (f *Functions) Relationships(ctx context.Context, node *Node, relType string) ([]*Relationship, error)
- func (f *Functions) RelationshipsIn(ctx context.Context, node *Node, relType string) ([]*Relationship, error)
- func (f *Functions) RelationshipsOut(ctx context.Context, node *Node, relType string) ([]*Relationship, error)
- type Node
- func AddLabel(node *Node, label string) *Node
- func AddLabels(node *Node, labels []string) *Node
- func Clone(node *Node) *Node
- func FromMap(m map[string]interface{}) *Node
- func RemoveLabel(node *Node, label string) *Node
- func RemoveLabels(node *Node, labels []string) *Node
- func RemoveProperties(node *Node, keys []string) *Node
- func RemoveProperty(node *Node, key string) *Node
- func SetProperties(node *Node, props map[string]interface{}) *Node
- func SetProperty(node *Node, key string, value interface{}) *Node
- type Relationship
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff compares two nodes and returns differences.
Example:
apoc.node.diff(node1, node2)
=> {added:{...}, removed:{...}, changed:{...}}
func HasLabel ¶
HasLabel checks if a node has a specific label.
Example:
apoc.node.hasLabel(node, 'Person') => true
func HasLabels ¶
HasLabels checks if a node has all specified labels.
Example:
apoc.node.hasLabels(node, ['Person', 'Employee']) => true
func Labels ¶
Labels returns the labels of a node.
Example:
apoc.node.labels(node) => ['Person', 'Employee']
func Properties ¶
Properties returns all properties of a node.
Example:
apoc.node.properties(node) => {name:'Alice', age:30}
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 ¶
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 ¶
Degree returns the degree (number of relationships) of a node.
Example:
apoc.node.degree(node) => 5
func (*Functions) DegreeIn ¶
DegreeIn returns the in-degree of a node.
Example:
apoc.node.degree.in(node, 'KNOWS') => 3
func (*Functions) DegreeOut ¶
DegreeOut returns the out-degree of a node.
Example:
apoc.node.degree.out(node, 'KNOWS') => 2
func (*Functions) IsDense ¶
IsDense checks if a node is dense (many relationships).
Example:
apoc.node.isDense(node) => true
func (*Functions) Neighbors ¶
Neighbors returns neighboring nodes.
Example:
apoc.node.neighbors(node, 'KNOWS') => [node1, node2, ...]
func (*Functions) NeighborsIn ¶
NeighborsIn returns incoming neighbors.
Example:
apoc.node.neighbors.in(node, 'KNOWS') => [node1, node2]
func (*Functions) NeighborsOut ¶
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 ¶
RelationshipTypes returns all relationship types of a node.
Example:
apoc.node.relationshipTypes(node) => ['KNOWS', 'WORKS_AT']
func (*Functions) RelationshipTypesIn ¶
RelationshipTypesIn returns incoming relationship types.
Example:
apoc.node.relationshipTypes.in(node) => ['KNOWS', 'FOLLOWS']
func (*Functions) RelationshipTypesOut ¶
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 ¶
Node represents a graph node.
func AddLabels ¶
AddLabels adds multiple labels to a node.
Example:
apoc.node.addLabels(node, ['Employee', 'Manager'])
func Clone ¶
Clone creates a copy of a node.
Example:
apoc.node.clone(node) => new node with same properties
func FromMap ¶
FromMap creates a node from a map.
Example:
apoc.node.fromMap({labels:['Person'], properties:{name:'Alice'}})
func RemoveLabel ¶
RemoveLabel removes a label from a node.
Example:
apoc.node.removeLabel(node, 'Employee')
func RemoveLabels ¶
RemoveLabels removes multiple labels from a node.
Example:
apoc.node.removeLabels(node, ['Employee', 'Manager'])
func RemoveProperties ¶
RemoveProperties removes multiple properties from a node.
Example:
apoc.node.removeProperties(node, ['age', 'city'])
func RemoveProperty ¶
RemoveProperty removes a property from a node.
Example:
apoc.node.removeProperty(node, 'age')
func SetProperties ¶
SetProperties sets multiple properties on a node.
Example:
apoc.node.setProperties(node, {age:31, city:'NYC'})
func SetProperty ¶
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.