create

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package create provides APOC dynamic creation functions.

This package implements all apoc.create.* functions for dynamically creating nodes and relationships in Cypher queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneSubgraph

func CloneSubgraph(nodes []*NodeData, rels []*RelData) ([]*NodeData, []*RelData)

CloneSubgraph clones a subgraph of nodes and relationships.

Example:

apoc.create.cloneSubgraph([node1, node2], [rel1])

func UUID

func UUID() string

UUID generates a UUID for a node.

Example:

apoc.create.uuid() => '550e8400-e29b-41d4-a716-446655440000'

func UUIDs

func UUIDs(count int) []string

UUIDs generates multiple UUIDs.

Example:

apoc.create.uuids(5) => ['uuid1', 'uuid2', ...]

func VPattern

func VPattern(startProps map[string]interface{}, relType string, relProps map[string]interface{}, endProps map[string]interface{}) (*NodeData, *RelData, *NodeData)

VPattern creates a virtual pattern (nodes and relationships).

Example:

apoc.create.vPattern({_labels:['Person'], name:'Alice'}, 'KNOWS', {}, {_labels:['Person'], name:'Bob'})

Types

type NodeData

type NodeData struct {
	ID         int64
	Labels     []string
	Properties map[string]interface{}
}

NodeData represents a graph node result.

func AddLabels

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

AddLabels adds labels to a node.

Example:

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

func Clone

func Clone(node *NodeData) *NodeData

Clone creates a copy of a node.

Example:

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

func Node

func Node(labels []string, properties map[string]interface{}) *NodeData

Node creates a new node with labels and properties.

Example:

apoc.create.node(['Person'], {name: 'Alice', age: 30})

func Nodes

func Nodes(labels []string, propertiesList []map[string]interface{}) []*NodeData

Nodes creates multiple nodes with the same labels.

Example:

apoc.create.nodes(['Person'], [{name:'Alice'}, {name:'Bob'}])

func RemoveLabels

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

RemoveLabels removes labels from a node.

Example:

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

func RemoveProperties

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

RemoveProperties removes properties from a node.

Example:

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

func SetProperties

func SetProperties(node *NodeData, properties map[string]interface{}) *NodeData

SetProperties sets multiple properties on a node.

Example:

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

func SetProperty

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

SetProperty sets a property on a node.

Example:

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

func VNode

func VNode(labels []string, properties map[string]interface{}) *NodeData

VNode creates a virtual node (not persisted).

Example:

apoc.create.vNode(['Person'], {name: 'Virtual'})

func VNodes

func VNodes(labels []string, propertiesList []map[string]interface{}) []*NodeData

VNodes creates multiple virtual nodes.

Example:

apoc.create.vNodes(['Person'], [{name:'A'}, {name:'B'}])

type RelData

type RelData struct {
	ID         int64
	Type       string
	StartNode  int64
	EndNode    int64
	Properties map[string]interface{}
}

RelData represents a graph relationship result.

func Relationship

func Relationship(from *NodeData, relType string, properties map[string]interface{}, to *NodeData) *RelData

Relationship creates a new relationship between nodes.

Example:

apoc.create.relationship(alice, 'KNOWS', {since: 2020}, bob)

func RemoveRelProperties

func RemoveRelProperties(rel *RelData, keys []string) *RelData

RemoveRelProperties removes properties from a relationship.

Example:

apoc.create.removeRelProperties(rel, ['weight'])

func SetRelProperties

func SetRelProperties(rel *RelData, properties map[string]interface{}) *RelData

SetRelProperties sets multiple properties on a relationship.

Example:

apoc.create.setRelProperties(rel, {weight: 0.8, since: 2020})

func SetRelProperty

func SetRelProperty(rel *RelData, key string, value interface{}) *RelData

SetRelProperty sets a property on a relationship.

Example:

apoc.create.setRelProperty(rel, 'weight', 0.8)

func VRelationship

func VRelationship(from *NodeData, relType string, properties map[string]interface{}, to *NodeData) *RelData

VRelationship creates a virtual relationship.

Example:

apoc.create.vRelationship(node1, 'KNOWS', {}, node2)

Jump to

Keyboard shortcuts

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