v4gil
v4gil

Reputation: 911

Update properties of many nodes selected by ID

This is a slightly different question from one answered here:

Update multiple nodes in a single query, each with different property / value pairs

The selected answer to that question presented a nifty query to update many nodes by their 'uuid':

UNWIND { data } AS d 
MERGE (x {uuid: d.uuid})
SET x += d.props

My question is how would you accomplish this if you wanted to select by ID(x)? While most of my nodes do have a uuid property, my relationships do not and I need to update their properties as well.

Thanks!

Upvotes: 0

Views: 527

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

You'll need to process your nodes and relationships separately. Relationships would process similar to this:

UNWIND { data } AS d 
MATCH ()-[r]-()
WHERE id(r) = d.id
SET r += d.props

Node processing would be similar, just use MATCH (n) WHERE id(n) = d.id

Upvotes: 1

Related Questions