maputil

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: 3 Imported by: 0

Documentation

Overview

Package map provides APOC map manipulation functions.

This package implements all apoc.map.* functions for working with maps/dictionaries in Cypher queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(m map[string]interface{}, keys []string, values []interface{}) map[string]interface{}

Clean removes null values from a map.

Example:

apoc.map.clean({a:1,b:null,c:3}, [], []) => {a:1,c:3}

func DropNullValues

func DropNullValues(m map[string]interface{}) map[string]interface{}

DropNullValues removes all null values from a map.

Example:

apoc.map.dropNullValues({a:1,b:null,c:3}) => {a:1,c:3}

func Flatten

func Flatten(m map[string]interface{}, delimiter string) map[string]interface{}

Flatten flattens a nested map structure.

Example:

apoc.map.flatten({a:{b:{c:1}}}) => {'a.b.c':1}

func FromLists

func FromLists(keys []interface{}, values []interface{}) map[string]interface{}

FromLists creates a map from separate key and value lists.

Example:

apoc.map.fromLists(['name','age'], ['Alice',30])
=> {name:'Alice', age:30}

func FromPairs

func FromPairs(pairs [][]interface{}) map[string]interface{}

FromPairs creates a map from a list of key-value pairs.

Example:

apoc.map.fromPairs([['name','Alice'],['age',30]])
=> {name:'Alice', age:30}

func FromValues

func FromValues(values []interface{}) map[string]interface{}

FromValues creates a map from alternating keys and values.

Example:

apoc.map.fromValues(['name','Alice','age',30])
=> {name:'Alice', age:30}

func Get

func Get(m map[string]interface{}, key string, defaultValue interface{}) interface{}

Get gets a value from a map with a default.

Example:

apoc.map.get({name:'Alice'}, 'age', 0) => 0

func GroupBy

func GroupBy(list []map[string]interface{}, key string) map[string][]map[string]interface{}

GroupBy groups a list of maps by a key.

Example:

apoc.map.groupBy([{type:'A',val:1},{type:'A',val:2},{type:'B',val:3}], 'type')
=> {A:[{type:'A',val:1},{type:'A',val:2}], B:[{type:'B',val:3}]}

func GroupByMulti

func GroupByMulti(list []map[string]interface{}, keys []string) map[string][]map[string]interface{}

GroupByMulti groups by multiple keys.

Example:

apoc.map.groupByMulti([...], ['type','category'])

func Keys

func Keys(m map[string]interface{}) []string

Keys returns all keys from a map.

Example:

apoc.map.keys({name:'Alice',age:30}) => ['name','age']

func MGet

func MGet(m map[string]interface{}, keys []string) []interface{}

MGet gets multiple values from a map.

Example:

apoc.map.mget({name:'Alice',age:30}, ['name','age'])
=> ['Alice', 30]

func Merge

func Merge(maps ...map[string]interface{}) map[string]interface{}

Merge merges multiple maps into one.

Example:

apoc.map.merge({a:1}, {b:2}, {c:3}) => {a:1, b:2, c:3}

func MergeList

func MergeList(maps []map[string]interface{}) map[string]interface{}

MergeList merges a list of maps.

Example:

apoc.map.mergeList([{a:1},{b:2},{c:3}]) => {a:1, b:2, c:3}

func RemoveKey

func RemoveKey(m map[string]interface{}, key string) map[string]interface{}

RemoveKey removes a key from a map.

Example:

apoc.map.removeKey({name:'Alice',age:30}, 'age')
=> {name:'Alice'}

func RemoveKeys

func RemoveKeys(m map[string]interface{}, keys []string) map[string]interface{}

RemoveKeys removes multiple keys from a map.

Example:

apoc.map.removeKeys({a:1,b:2,c:3}, ['b','c']) => {a:1}

func SetEntry

func SetEntry(m map[string]interface{}, key string, value interface{}) map[string]interface{}

SetEntry sets a key-value pair in a map.

Example:

apoc.map.setEntry({name:'Alice'}, 'age', 30)

func SetKey

func SetKey(m map[string]interface{}, key string, value interface{}) map[string]interface{}

SetKey sets a key in a map.

Example:

apoc.map.setKey({name:'Alice'}, 'age', 30)
=> {name:'Alice', age:30}

func SetLists

func SetLists(m map[string]interface{}, keys []interface{}, values []interface{}) map[string]interface{}

SetLists sets keys from two lists.

Example:

apoc.map.setLists({}, ['name','age'], ['Alice',30])

func SetPairs

func SetPairs(m map[string]interface{}, pairs [][]interface{}) map[string]interface{}

SetPairs sets multiple key-value pairs in a map.

Example:

apoc.map.setPairs({}, [['name','Alice'],['age',30]])

func SetValues

func SetValues(m map[string]interface{}, values []interface{}) map[string]interface{}

SetValues sets keys from alternating key-value list.

Example:

apoc.map.setValues({}, ['name','Alice','age',30])

func SortedProperties

func SortedProperties(m map[string]interface{}) [][]interface{}

SortedProperties returns key-value pairs sorted by key.

Example:

apoc.map.sortedProperties({z:1,a:2}) => [['a',2],['z',1]]

func SubMap

func SubMap(m map[string]interface{}, keys []string) map[string]interface{}

SubMap extracts a subset of a map by keys.

Example:

apoc.map.submap({a:1,b:2,c:3}, ['a','c']) => {a:1,c:3}

func Unflatten

func Unflatten(m map[string]interface{}, delimiter string) map[string]interface{}

Unflatten unflattens a flat map into nested structure.

Example:

apoc.map.unflatten({'a.b.c':1}) => {a:{b:{c:1}}}

func UpdateTree

func UpdateTree(m map[string]interface{}, path string, value interface{}) map[string]interface{}

UpdateTree updates a nested map structure.

Example:

apoc.map.updateTree({a:{b:1}}, 'a.b', 2) => {a:{b:2}}

func Values

func Values(m map[string]interface{}) []interface{}

Values returns all values from a map.

Example:

apoc.map.values({name:'Alice',age:30}) => ['Alice',30]

Types

This section is empty.

Jump to

Keyboard shortcuts

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