javascript - 通过 "MATCH (n) DETACH DELETE n"运行 "neo4j-driver"不起作用

标签 javascript typescript neo4j bolt neo4j-driver

我正在测试 neo4j-driver package通过 JavaScript/TypeScript 运行 Cypher 查询。

我可以很好地运行大多数查询,但每次我尝试运行命令 MATCH (n) DETACH DELETE n 我的程序总是挂起,什么也没有发生。

我的代码:

// main.ts

import neo4j from "neo4j-driver"

const main = async () => {
  const driver = neo4j.driver("bolt://localhost:7687",
    neo4j.auth.basic("neo4j", "telmo"))

  const session = driver.session()

  console.log("This command works fine")
  await session.run(`CREATE (n:Person {name: "Bob"}) RETURN n.name`)

  console.log("This one does not")
  await session.run("MATCH (n) DETACH DELETE n")

  console.log("The code never even gets here")

  session.close()
  driver.close()
}

main()

有谁知道为什么程序在 MATCH (n) DETACH DELETE n 上挂起,我该如何修复它?请注意,我的数据库仅用于测试,并且数据量非常少。

最佳答案

当您执行 match(n) detach delete n ..它会加载图中的所有关系和节点,并且您的堆大小可能不足以一次加载所有数据。尝试使用以下查询来批量执行作业, 调用 apoc.periodic.iterate( “匹配(n)返回n”, “DETACH DELETE n”,{batchSize:10000,并行:false})

在此处了解有关 apoc.iterate 的更多信息 http://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/cypher-execution/commit-batching/

关于javascript - 通过 "MATCH (n) DETACH DELETE n"运行 "neo4j-driver"不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59516993/

相关文章:

Angular 形式验证 : compare two fields in different form groups

javascript - 我如何提供一个检测文件夹来运行我的 Cypress 测试?

database - 使用 Neo4j 执行任意查询

neo4j - 节点类别作为标签、作为节点还是作为标签和节点?

javascript - 无法让复选框停止显示隐藏的 Div

javascript - 如何显示所选按钮的值?

javascript - 我如何在同一目录中需要来自 index.js 的内容?

javascript - KnockoutJS - ViewModel(祖 parent - parent - child )访问子元素中的父函数

javascript - Ionic/Angular HttpClient 未获取类型数据 : error Property 'name' does not exist on type '{}'

redis - Neo4j 的 Cypher 查询语言是开源的吗?