apoc.merge.relationshipWithStats.eagerProcedure
Syntax |
|
||
Description |
Merges the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The start node of the relationship. |
|
|
|
The type of the relationship. |
|
|
|
Properties on the relationship that are always merged. |
|
|
|
Properties that are merged when a relationship is created. |
|
|
|
The end node of the relationship. |
|
|
|
Properties that are merged when a relationship is matched. The default is: |
|
Return arguments |
Name |
Type |
Description |
|
|
The returned query statistics. |
|
|
|
The updated relationship. |
|
Example
Given this dataset:
CREATE (:Person {name: 'Alice'}), (:Person {name: 'Bob'})
The following query merges a KNOWS relationship between two existing nodes and returns the relationship alongside query statistics:
MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
CALL
apoc.merge.relationshipWithStats.eager(
a,
'KNOWS',
{id: 1},
{since: 2019},
b,
{}
)
YIELD rel, stats
RETURN
type(rel) AS type,
rel.id AS id,
rel.since AS since,
stats.relationshipsCreated AS relationshipsCreated,
stats.propertiesSet AS propertiesSet
| type | id | since | relationshipsCreated | propertiesSet |
|---|---|---|---|---|
"KNOWS" |
1 |
2019 |
1 |
2 |
Produces the same result as apoc.merge.relationshipWithStats.
The eager variant fully materializes all results before returning, which prevents conflicts when the procedure is used inside a larger
query that also reads or writes relationships of the same type.