Documentation
¶
Overview ¶
Package refactor provides APOC graph refactoring functions.
This package implements all apoc.refactor.* functions for restructuring and transforming graph data.
Index ¶
- type Functions
- func (f *Functions) CloneNodes(ctx context.Context, nodes []*Node) ([]*Node, error)
- func (f *Functions) CloneSubgraph(ctx context.Context, nodes []*Node, rels []*Relationship) (map[string]interface{}, error)
- func (f *Functions) CloneSubgraphFromPaths(ctx context.Context, paths []map[string]interface{}) (map[string]interface{}, error)
- func (f *Functions) CollapseNode(ctx context.Context, node *Node, relType string) ([]*Relationship, error)
- func (f *Functions) DeleteAndReconnect(ctx context.Context, nodes []*Node, relType string) (int, error)
- func (f *Functions) Denormalize(ctx context.Context, node *Node, relType, property string) (*Node, error)
- func (f *Functions) ExtractNode(ctx context.Context, rel *Relationship, labels []string, ...) (*Node, error)
- func (f *Functions) Normalize(ctx context.Context, node *Node, property, newLabel, relType string) (map[string]interface{}, error)
- func (f *Functions) RenameLabel(ctx context.Context, oldLabel, newLabel string) (int, error)
- func (f *Functions) RenameProperty(ctx context.Context, oldName, newName string) (int, error)
- func (f *Functions) RenameRelProperty(ctx context.Context, oldName, newName string) (int, error)
- func (f *Functions) RenameType(ctx context.Context, oldType, newType string) (int, error)
- type Node
- type Relationship
- func ChangeType(rel *Relationship, newType string, config map[string]interface{}) *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 ¶
This section is empty.
Functions ¶
This section is empty.
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) CloneNodes ¶
CloneNodes clones nodes with new IDs.
Example:
apoc.refactor.cloneNodes([node1, node2]) => cloned nodes
func (*Functions) CloneSubgraph ¶
func (f *Functions) CloneSubgraph(ctx context.Context, nodes []*Node, rels []*Relationship) (map[string]interface{}, error)
CloneSubgraph clones a subgraph.
Example:
apoc.refactor.cloneSubgraph([node1, node2], [rel1]) => {nodes: [...], rels: [...]}
func (*Functions) CloneSubgraphFromPaths ¶
func (f *Functions) CloneSubgraphFromPaths(ctx context.Context, paths []map[string]interface{}) (map[string]interface{}, error)
CloneSubgraphFromPaths clones subgraph from paths.
Example:
apoc.refactor.cloneSubgraphFromPaths(paths) => {nodes: [...], rels: [...]}
func (*Functions) CollapseNode ¶
func (f *Functions) CollapseNode(ctx context.Context, node *Node, relType string) ([]*Relationship, error)
CollapseNode collapses a node by connecting its neighbors.
Example:
apoc.refactor.collapseNode(node, 'CONNECTED') => relationships created
func (*Functions) DeleteAndReconnect ¶
func (f *Functions) DeleteAndReconnect(ctx context.Context, nodes []*Node, relType string) (int, error)
DeleteAndReconnect deletes nodes and reconnects neighbors.
Example:
apoc.refactor.deleteAndReconnect([node1, node2], 'CONNECTED') => count
func (*Functions) Denormalize ¶
func (f *Functions) Denormalize(ctx context.Context, node *Node, relType, property string) (*Node, error)
Denormalize denormalizes graph structure.
Example:
apoc.refactor.denormalize(node, 'HAS', 'property') => denormalized
func (*Functions) ExtractNode ¶
func (f *Functions) ExtractNode(ctx context.Context, rel *Relationship, labels []string, props map[string]interface{}) (*Node, error)
ExtractNode extracts a node from a relationship.
Example:
apoc.refactor.extractNode(rel, ['Person'], {name: 'Intermediate'}) => node
func (*Functions) Normalize ¶
func (f *Functions) Normalize(ctx context.Context, node *Node, property, newLabel, relType string) (map[string]interface{}, error)
Normalize normalizes graph structure.
Example:
apoc.refactor.normalize(node, 'property', 'NewLabel', 'HAS') => normalized
func (*Functions) RenameLabel ¶
RenameLabel renames a label on all nodes that have it.
Example:
apoc.refactor.rename.label('OldLabel', 'NewLabel') => count
func (*Functions) RenameProperty ¶
RenameProperty renames a property on all nodes that have it.
Example:
apoc.refactor.rename.nodeProperty('oldName', 'newName') => count
func (*Functions) RenameRelProperty ¶
RenameRelProperty renames a property on all relationships that have it.
Example:
apoc.refactor.rename.relProperty('oldName', 'newName') => count
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 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 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