Foreach

本页介绍如何使用 Cypher®.Foreach 类创建 FOREACH 子句。

一个 Foreach 子句接受一个用于循环的变量。使用 .in.do 方法分别定义列表和更新子句。

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 })
)
© . This site is unofficial and not affiliated with Neo4j, Inc.