neo4j - Neo4j - 删除节点
问题描述
在我的 Neo4j 数据库中,有些节点的ref字段的值等于其他节点中存在的id字段。换句话说,它是一个 XML 文件,其中一些节点引用了其他节点。有没有办法删除这些节点?
解决方案
如果我理解,您正在尝试删除一组节点,其ref
属性值等于id
另一组节点的属性之一。如果是这样,您可以使用这样的 Cypher 查询来执行此操作:
match (n1:Node)
// store all ids into a collection called 'ids'
with collect(distinct n1.id) as ids
// match all nodes that 'ref' property equal to any value in 'ids'
match (n2:Node)
where n2.ref in ids
// delete all n2 nodes and its relationships
detach delete n2
推荐阅读
- express - 将获取请求重定向到发布请求?使用快递
- c# - 使用承载身份验证时未发送正文
- c# - 传递给函数(但不是本地)时列表元素的意外不平等
- leaflet - 如何解决 Leaflet TypeError:L.control.selectLayers 不是函数
- sql - 连接 3 个表时重复值
- java - 如果 Parse 服务器本身已关闭, saveEventually() 会起作用吗?
- javascript - 点击图片时如何弹出小窗口?
- java - 验证 char 用户输入循环
- three.js - Three.js:使光线投射器的方向与物体的方向相同
- magento - XAMPP 上的 Windows 10 Magento 2.4 zip 安装无处同意条款