diff

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package diff provides APOC diff operations.

This package implements all apoc.diff.* functions for comparing and finding differences between nodes, relationships, and data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deep

func Deep(value1, value2 interface{}) bool

Deep performs a deep comparison of two values.

Example:

apoc.diff.deep(value1, value2) => true/false

func Lists

func Lists(list1, list2 []interface{}) map[string]interface{}

Lists compares two lists and returns differences.

Example:

apoc.diff.lists([1, 2, 3], [2, 3, 4]) => {added: [4], removed: [1], common: [2, 3]}

func Merge

func Merge(map1, map2 map[string]interface{}, strategy string) map[string]interface{}

Merge merges two maps with conflict resolution.

Example:

apoc.diff.merge(map1, map2, 'prefer_new') => merged map

func Patch

func Patch(original map[string]interface{}, diff *DiffResult) map[string]interface{}

Patch applies a diff patch to a map.

Example:

apoc.diff.patch(original, diff) => patched map

func Strings

func Strings(str1, str2 string) []map[string]interface{}

Strings compares two strings and returns character-level differences.

Example:

apoc.diff.strings('hello', 'hallo') => differences

func Summary

func Summary(diff *DiffResult) map[string]int

Summary provides a summary of differences.

Example:

apoc.diff.summary(diff) => {added: 2, removed: 1, changed: 3}

Types

type DiffResult

type DiffResult struct {
	Added     map[string]interface{}
	Removed   map[string]interface{}
	Changed   map[string]interface{}
	Unchanged map[string]interface{}
}

DiffResult represents the result of a diff operation.

func Maps

func Maps(map1, map2 map[string]interface{}) *DiffResult

Maps compares two maps and returns differences.

Example:

apoc.diff.maps({a: 1}, {a: 2, b: 3}) => {added: {b: 3}, changed: {a: {old: 1, new: 2}}}

func Nodes

func Nodes(node1, node2 *Node) *DiffResult

Nodes compares two nodes and returns differences.

Example:

apoc.diff.nodes(node1, node2) => {added: {...}, removed: {...}, changed: {...}}

func Relationships

func Relationships(rel1, rel2 *Relationship) *DiffResult

Relationships compares two relationships and returns differences.

Example:

apoc.diff.relationships(rel1, rel2) => {added: {...}, removed: {...}, changed: {...}}

type Node

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

Node represents a graph node.

type Relationship

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

Relationship represents a graph relationship.

Jump to

Keyboard shortcuts

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