apoc.atomic.insert
Syntax |
|
||
Description |
Inserts a value at position into the |
||
Input arguments |
Name |
Type |
Description |
|
|
The node or relationship that has a property containing a list. |
|
|
|
The name of the property into which the value will be inserted. |
|
|
|
The position in the list to insert the item into. |
|
|
|
The value to insert. |
|
|
|
The max retry attempts. The default is: |
|
Return arguments |
Name |
Type |
Description |
|
|
The updated node or relationship. |
|
|
|
The name of the updated property. |
|
|
|
The original value on the property. |
|
|
|
The new value on the property. |
Usage examples
The examples in this section are based on the following sample graph:
CREATE (:Person {name:'Tom',age: 40})
CREATE (:Person {name:'Will',age: 35})
CREATE (:Person {name:'David', children: ['Anne','Sam','Paul']})
CREATE (:Person {name:'John', cars: ['Class A','X3','Focus']})
CREATE (:Person {name:'Ryan', salary1:1800, salary2:1500});
The following adds Mary
in position 2 of children
list:
MATCH (p:Person {name:'David'})
CALL apoc.atomic.insert(p,'children',2,'Mary',5)
YIELD oldValue, newValue
RETURN oldValue, newValue;
oldValue | newValue |
---|---|
["Anne", "Sam", "Paul"] |
["Anne", "Sam", "Mary", "Paul"] |