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 ¶
- func Clean(m map[string]interface{}, keys []string, values []interface{}) map[string]interface{}
- func DropNullValues(m map[string]interface{}) map[string]interface{}
- func Flatten(m map[string]interface{}, delimiter string) map[string]interface{}
- func FromLists(keys []interface{}, values []interface{}) map[string]interface{}
- func FromPairs(pairs [][]interface{}) map[string]interface{}
- func FromValues(values []interface{}) map[string]interface{}
- func Get(m map[string]interface{}, key string, defaultValue interface{}) interface{}
- func GroupBy(list []map[string]interface{}, key string) map[string][]map[string]interface{}
- func GroupByMulti(list []map[string]interface{}, keys []string) map[string][]map[string]interface{}
- func Keys(m map[string]interface{}) []string
- func MGet(m map[string]interface{}, keys []string) []interface{}
- func Merge(maps ...map[string]interface{}) map[string]interface{}
- func MergeList(maps []map[string]interface{}) map[string]interface{}
- func RemoveKey(m map[string]interface{}, key string) map[string]interface{}
- func RemoveKeys(m map[string]interface{}, keys []string) map[string]interface{}
- func SetEntry(m map[string]interface{}, key string, value interface{}) map[string]interface{}
- func SetKey(m map[string]interface{}, key string, value interface{}) map[string]interface{}
- func SetLists(m map[string]interface{}, keys []interface{}, values []interface{}) map[string]interface{}
- func SetPairs(m map[string]interface{}, pairs [][]interface{}) map[string]interface{}
- func SetValues(m map[string]interface{}, values []interface{}) map[string]interface{}
- func SortedProperties(m map[string]interface{}) [][]interface{}
- func SubMap(m map[string]interface{}, keys []string) map[string]interface{}
- func Unflatten(m map[string]interface{}, delimiter string) map[string]interface{}
- func UpdateTree(m map[string]interface{}, path string, value interface{}) map[string]interface{}
- func Values(m map[string]interface{}) []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
Clean removes null values from a map.
Example:
apoc.map.clean({a:1,b:null,c:3}, [], []) => {a:1,c:3}
func DropNullValues ¶
DropNullValues removes all null values from a map.
Example:
apoc.map.dropNullValues({a:1,b:null,c:3}) => {a:1,c:3}
func Flatten ¶
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 ¶
Get gets a value from a map with a default.
Example:
apoc.map.get({name:'Alice'}, 'age', 0) => 0
func GroupBy ¶
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 ¶
GroupByMulti groups by multiple keys.
Example:
apoc.map.groupByMulti([...], ['type','category'])
func Keys ¶
Keys returns all keys from a map.
Example:
apoc.map.keys({name:'Alice',age:30}) => ['name','age']
func MGet ¶
MGet gets multiple values from a map.
Example:
apoc.map.mget({name:'Alice',age:30}, ['name','age'])
=> ['Alice', 30]
func Merge ¶
Merge merges multiple maps into one.
Example:
apoc.map.merge({a:1}, {b:2}, {c:3}) => {a:1, b:2, c:3}
func MergeList ¶
MergeList merges a list of maps.
Example:
apoc.map.mergeList([{a:1},{b:2},{c:3}]) => {a:1, b:2, c:3}
func RemoveKey ¶
RemoveKey removes a key from a map.
Example:
apoc.map.removeKey({name:'Alice',age:30}, 'age')
=> {name:'Alice'}
func RemoveKeys ¶
RemoveKeys removes multiple keys from a map.
Example:
apoc.map.removeKeys({a:1,b:2,c:3}, ['b','c']) => {a:1}
func SetEntry ¶
SetEntry sets a key-value pair in a map.
Example:
apoc.map.setEntry({name:'Alice'}, 'age', 30)
func SetKey ¶
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 ¶
SetPairs sets multiple key-value pairs in a map.
Example:
apoc.map.setPairs({}, [['name','Alice'],['age',30]])
func SetValues ¶
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 ¶
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 ¶
Unflatten unflattens a flat map into nested structure.
Example:
apoc.map.unflatten({'a.b.c':1}) => {a:{b:{c:1}}}
func UpdateTree ¶
UpdateTree updates a nested map structure.
Example:
apoc.map.updateTree({a:{b:1}}, 'a.b', 2) => {a:{b:2}}
Types ¶
This section is empty.