将 FOREACH 中的 MERGE 与密码脚本中的事务结合起来 目的现在看起来像这样但我收到以下错误:

问题描述

我正在尝试制作一个在 cypher-shell 中使用的密码脚本文件。

目的

结果应该是一堆名为“Constant”的节点。对于一些我只是使用地图作为属性,对于其他人我另外尝试设置一个createdAt属性dynamically。所有这一切都应该发生在一个 FOREACH 中,包裹在一个 transaction 中。

现在看起来像这样

:begin
WITH [
        {type: 'singleHouse',debug: true},{type: 'apartmentHouse',debug: true }
    ] AS constantHouseholdTypes
    FOREACH (constantHouseholdType in constantHouseholdTypes | CREATE (n:Constant:HouseholdType) SET n=constantHouseholdType);
:commit

:begin
WITH [
        {name: 'unit:area:squareMeter',domain: 'area',scaling: false,debug: true}
    ] as units
    FOREACH (unit in units | CREATE (u:Constant:Unit) SET u=unit,u.createdAt = timestamp())
:commit

编辑:没有错误了

我不再因为任何原因看到错误。

版本: 螺栓:4.2 Neo4J 4.2.3

但我收到以下错误:

Invalid input ':': expected 
  <EOF>
  "RETURN"
  "CREATE"
  "DELETE"
  "SET"
  "REMOVE"
  "DETACH"
  "MATCH"
  "WITH"
  "UNWIND"
  "USE"
  "CALL"
  "LOAD"
  "FROM"
  "FOREACH"
  "MERGE"
  "OPTIONAL"
  "UNION" (line 7,column 1 (offset: 207))
":commit"
 ^

并且没有添加任何节点(这正是交易中出现错误时应该发生的情况):

MATCH (c:Constant) RETURN c;
+---+
| c |
+---+
+---+

0 rows available after 5 ms,consumed after another 2 ms

知道吗,我到底做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)