apoc.merge.nodeWithStats.eager

Details

Syntax

apoc.merge.nodeWithStats.eager(labels, identProps [, onCreateProps, onMatchProps ]) :: (stats, node)

Description

Merges the given NODE values with the given dynamic labels eagerly. Provides queryStatistics in the result.

Input arguments

Name

Type

Description

labels

LIST<STRING>

The list of labels used for the generated MERGE statement.

identProps

MAP

Properties on the node that are always merged.

onCreateProps

MAP

Properties that are merged when a node is created. The default is: {}.

onMatchProps

MAP

Properties that are merged when a node is matched. The default is: {}.

Return arguments

Name

Type

Description

stats

MAP

The returned query statistics.

node

NODE

The updated node.

Example

The following query merges a Person node using id as the identifying property and name and age as on-create properties, returning the node alongside query statistics:

CALL
  apoc.merge.nodeWithStats.eager(
    ['Person'],
    {id: 1},
    {name: 'Alice', age: 30},
    {}
  )
  YIELD node, stats
RETURN
  node.id AS id,
  node.name AS name,
  node.age AS age,
  stats.nodesCreated AS nodesCreated,
  stats.propertiesSet AS propertiesSet
Results
id name age nodesCreated propertiesSet

1

"Alice"

30

1

3

Produces the same result as apoc.merge.nodeWithStats. 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 nodes matching the same labels and properties.