apoc.atomic.remove

Details

Syntax

apoc.atomic.remove(container, propertyName, position [, retryAttempts ]) :: (container, property, oldValue, newValue)

Description

Removes the element at position from the LIST<ANY> value of a property. The procedure then sets the property to the resulting LIST<ANY> value.

Input arguments

Name

Type

Description

container

ANY

The node or relationship that has a property containing a list.

propertyName

STRING

The name of the property from which the value will be removed.

position

INTEGER

The position in the list to remove the item from.

retryAttempts

INTEGER

The max retry attempts. The default is: 5.

Return arguments

Name

Type

Description

container

ANY

The updated node or relationship.

property

STRING

The name of the updated property.

oldValue

ANY

The original value on the property.

newValue

ANY

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 removes the element X3, which is at position 1, from the array cars

MATCH (p:Person {name:'John'})
CALL apoc.atomic.remove(p,'cars',1,5)
YIELD oldValue, newValue
RETURN oldValue, newValue;
Results
oldValue newValue

["Class A", "X3", "Focus"]

["Class A", "Focus"]