Foreach
This page describes how to create a FOREACH clause using the Cypher®.Foreach class.
A Foreach clause takes a single variable to be used in a loop.
Use the .in and .do methods to define the list and update clauses respectively:
const x = new Cypher.Variable();
const query = new Cypher.Foreach(x).in(new Cypher.Param([1, 2, 3])).do(
new Cypher.Create(
new Cypher.Pattern({
labels: ["Movie"],
properties: {
id: x,
},
})
)
);
FOREACH (var0 IN $param0 |
CREATE (:Movie { id: var0 })
)