简体   繁体   English

如何使用Neo4J上的密码查询删除特定节点的所有属性

[英]How can I delete all the properties of a particular node using a cypher query on Neo4J

我需要获取节点的现有属性并删除除id之外的所有节点属性。

Found the answer on https://markhneedham.com/blog/2019/03/14/neo4j-delete-dynamic-properties/ https://markhneedham.com/blog/2019/03/14/neo4j-delete-dynamic-properties/上找到答案

MATCH (n:person)
WITH n, [k in keys(n) where not k in ["id","_int_version"]] as keys
CALL apoc.create.removeProperties(n, keys) YIELD node
RETURN node;

The easiest way is actually to set a map on the node (this replaces the properties of the node with the properties in the map, and ensuring the map only contains the projected properties you want to keep: 最简单的方法是在节点上设置一个地图(这将使用地图中的属性替换节点的属性,并确保地图仅包含您要保留的投影属性:

MATCH (n:person)
WITH n, n {.id, ._int_version} as propsToKeep
SET n = propsToKeep

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM