apoc.cypher.runMany

详细信息

语法

apoc.cypher.runMany(statement, params [, config ]) :: (row, result)

描述

运行以分号分隔的每条语句,并返回语句执行结果的摘要。

输入参数

名称

类型

描述

statement

STRING

要运行的 Cypher 语句,以分号 (;) 分隔。

params

MAP

给定 Cypher 语句的参数。

config

MAP

{ statistics = true :: BOOLEAN }。默认值为:{}

返回参数

名称

类型

描述

row

INTEGER(整数)

所运行 Cypher 语句的行号。

结果

MAP

Cypher 语句返回的结果。

此过程无法执行 SCHEMA(模式)操作。如需在 SCHEMA 模式下运行查询,请使用 apoc.cypher.runSchema

用法示例

此过程适用于执行多条 Cypher 语句。我们可以通过运行以下查询,在一个语句中创建一个节点,并在另一个语句中创建指向它自身的关联:

CALL apoc.cypher.runMany(
  'CREATE (n:Node {name:$name});
   MATCH (n {name:$name})
   CREATE (n)-[:X {name:$name2}]->(n);',
  {name:"John", name2:"Doe"}
);
结果
row 结果

-1

{constraintsRemoved: 0, indexesRemoved: 0, nodesCreated: 1, rows: 0, propertiesSet: 1, labelsRemoved: 0, relationshipsDeleted: 0, constraintsAdded: 0, nodesDeleted: 0, indexesAdded: 0, labelsAdded: 1, relationshipsCreated: 0, time: 0}

-1

{constraintsRemoved: 0, indexesRemoved: 0, nodesCreated: 0, rows: 0, propertiesSet: 1, labelsRemoved: 0, relationshipsDeleted: 0, constraintsAdded: 0, nodesDeleted: 0, indexesAdded: 0, labelsAdded: 0, relationshipsCreated: 1, time: 0}

如果我们不想查看每条 Cypher 语句的统计信息,可以将 statistics 设置为 false

CALL apoc.cypher.runMany(
  'CREATE (n:Node {name:$name});
   MATCH (n {name:$name})
   CREATE (n)-[:X {name:$name2}]->(n);',
  {name:"John", name2:"Doe"},
  {statistics: false}
);
结果
row 结果