Documentation
¶
Overview ¶
Package refactor provides APOC graph refactoring functions.
This package implements all apoc.refactor.* functions for restructuring and transforming graph data.
Index ¶
- Variables
- func CloneSubgraph(nodes []*Node, rels []*Relationship) map[string]interface{}
- func CloneSubgraphFromPaths(paths []map[string]interface{}) map[string]interface{}
- func DeleteAndReconnect(nodes []*Node, relType string) int
- func Normalize(node *Node, property, newLabel, relType string) map[string]interface{}
- func RenameLabel(oldLabel, newLabel string) int
- func RenameProperty(oldName, newName string) int
- func RenameRelProperty(oldName, newName string) int
- func RenameType(oldType, newType string) int
- type Node
- func CategorizeProperty(node *Node, property, newProperty string, categories [][]interface{}) *Node
- func CloneNodes(nodes []*Node) []*Node
- func Denormalize(node *Node, relType, property string) *Node
- func ExtractNode(rel *Relationship, labels []string, props map[string]interface{}) *Node
- func MergeNodes(nodes []*Node, config map[string]interface{}) *Node
- func NormalizeAsBoolean(node *Node, property string, trueValues, falseValues []string) *Node
- type Relationship
- func ChangeType(rel *Relationship, newType string, config map[string]interface{}) *Relationship
- func CollapseNode(node *Node, relType string) []*Relationship
- func From(rel *Relationship, newStart *Node) *Relationship
- func InvertRelationship(rel *Relationship) *Relationship
- func MergeRelationships(rels []*Relationship, config map[string]interface{}) *Relationship
- func RedirectRelationship(rel *Relationship, newEnd *Node) *Relationship
- func SetType(rel *Relationship, newType string) *Relationship
Constants ¶
This section is empty.
Variables ¶
var Storage storage.Storage = storage.NewInMemoryStorage()
Storage is the interface for database operations.
Functions ¶
func CloneSubgraph ¶
func CloneSubgraph(nodes []*Node, rels []*Relationship) map[string]interface{}
CloneSubgraph clones a subgraph.
Example:
apoc.refactor.cloneSubgraph([node1, node2], [rel1]) => {nodes: [...], rels: [...]}
func CloneSubgraphFromPaths ¶
CloneSubgraphFromPaths clones subgraph from paths.
Example:
apoc.refactor.cloneSubgraphFromPaths(paths) => {nodes: [...], rels: [...]}
func DeleteAndReconnect ¶
DeleteAndReconnect deletes nodes and reconnects neighbors.
Example:
apoc.refactor.deleteAndReconnect([node1, node2], 'CONNECTED') => count
func Normalize ¶
Normalize normalizes graph structure.
Example:
apoc.refactor.normalize(node, 'property', 'NewLabel', 'HAS') => normalized
func RenameLabel ¶
RenameLabel renames a label on all nodes that have it.
Example:
apoc.refactor.rename.label('OldLabel', 'NewLabel') => count
func RenameProperty ¶
RenameProperty renames a property on all nodes that have it.
Example:
apoc.refactor.rename.nodeProperty('oldName', 'newName') => count
func RenameRelProperty ¶
RenameRelProperty renames a property on all relationships that have it.
Example:
apoc.refactor.rename.relProperty('oldName', 'newName') => count
func RenameType ¶
RenameType renames a relationship type on all relationships.
Example:
apoc.refactor.rename.type('OLD_TYPE', 'NEW_TYPE') => count
Types ¶
type Node ¶
Node represents a graph node.
func CategorizeProperty ¶
CategorizeProperty categorizes a property value.
Example:
apoc.refactor.categorize(node, 'age', 'ageGroup', [[0,18,'child'], [18,65,'adult']])
func CloneNodes ¶
CloneNodes clones nodes with new IDs.
Example:
apoc.refactor.cloneNodes([node1, node2]) => cloned nodes
func Denormalize ¶
Denormalize denormalizes graph structure.
Example:
apoc.refactor.denormalize(node, 'HAS', 'property') => denormalized
func ExtractNode ¶
func ExtractNode(rel *Relationship, labels []string, props map[string]interface{}) *Node
ExtractNode extracts a node from a relationship.
Example:
apoc.refactor.extractNode(rel, ['Person'], {name: 'Intermediate'}) => node
func MergeNodes ¶
MergeNodes merges multiple nodes into one.
Example:
apoc.refactor.mergeNodes([node1, node2], {properties: 'combine'}) => merged node
type Relationship ¶
type Relationship = storage.Relationship
Relationship represents a graph relationship.
func ChangeType ¶
func ChangeType(rel *Relationship, newType string, config map[string]interface{}) *Relationship
ChangeType changes relationship type with properties.
Example:
apoc.refactor.changeType(rel, 'NEW_TYPE', {keepProps: true})
func CollapseNode ¶
func CollapseNode(node *Node, relType string) []*Relationship
CollapseNode collapses a node by connecting its neighbors.
Example:
apoc.refactor.collapseNode(node, 'CONNECTED') => relationships created
func From ¶
func From(rel *Relationship, newStart *Node) *Relationship
From redirects relationship from a new node.
Example:
apoc.refactor.from(rel, newStartNode) => relationship
func InvertRelationship ¶
func InvertRelationship(rel *Relationship) *Relationship
InvertRelationship inverts relationship direction.
Example:
apoc.refactor.invert(rel) => inverted relationship
func MergeRelationships ¶
func MergeRelationships(rels []*Relationship, config map[string]interface{}) *Relationship
MergeRelationships merges multiple relationships into one.
Example:
apoc.refactor.mergeRelationships([rel1, rel2]) => merged relationship
func RedirectRelationship ¶
func RedirectRelationship(rel *Relationship, newEnd *Node) *Relationship
RedirectRelationship redirects a relationship to a new node.
Example:
apoc.refactor.to(rel, newEndNode) => relationship
func SetType ¶
func SetType(rel *Relationship, newType string) *Relationship
SetType changes relationship type.
Example:
apoc.refactor.setType(rel, 'NEW_TYPE') => relationship