Lundin
Lundin

Reputation: 311

How to make multiple operations in a FOREACH loop?

I was trying to adding some path AND node operations in a foreach collect function, however i am only able to do a single operation in every foreach for example:

FOREACH (value IN Allissues | 
     SET issues.prodstatus=false)

However what if multiple events needs to happen then this does not work

FOREACH (value IN Allissues | 
     SET issues.prodstatus=false,CREATE (problem)-[:REQUEST]-(user))

Instead i have to do multiple FOREACH for every operation making the code look non DRY, does that add any penalty or is it possible to create AND set in one single go?

Upvotes: 2

Views: 1581

Answers (1)

Jacob Davis-Hansson
Jacob Davis-Hansson

Reputation: 2663

Yes, this is possible. Simply drop the comma from the second query:

FOREACH (value IN Allissues | 
   SET issues.prodstatus=false
   CREATE (problem)-[:REQUEST]-(user))

Upvotes: 5

Related Questions