apoc.lock.nodesProcedure
|
This procedure is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime. For more information, see the Cypher Manual → Parallel runtime. |
Syntax |
|
||
Description |
Acquires a write lock on the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The list of nodes to acquire a write lock on. |
|
Example
Given this dataset:
CREATE (:Person {name: 'Alice', age: 30})-[:KNOWS {since: 2019}]->(:Person {name: 'Bob', age: 25})
The following query acquires a write lock on a node before updating its property, preventing other transactions from reading or writing it until this transaction completes:
MATCH (n:Person {name: 'Alice'})
CALL apoc.lock.nodes([n])
SET n.age = n.age + 1
RETURN n.name AS name, n.age AS age
| name | age |
|---|---|
"Alice" |
31 |