apoc.atomic.subtract
Syntax |
|
||
Description |
Sets the property of a value to itself minus the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The node or relationship that contains the property from which the value will be subtracted. |
|
|
|
The name of the property from which the value will be subtracted. |
|
|
|
The number to subtract. |
|
|
|
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 subtracts 10 from the property age
for Tom
:
MATCH (n:Person {name:'Tom'})
CALL apoc.atomic.subtract(n,'age',10,5)
YIELD oldValue, newValue
RETURN oldValue, newValue;
oldValue | newValue |
---|---|
40 |
30 |