简体   繁体   中英

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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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