apoc.create.removeProperties过程Cypher 25 中已弃用
|
此过程已弃用。如需动态删除属性,请改用 Cypher 的 |
语法 |
|
||
描述 |
从给定的 |
||
输入参数 |
名称 |
类型 |
描述 |
|
|
要从中删除属性的节点。 |
|
|
|
要从给定节点中删除的属性键。 |
|
返回参数 |
名称 |
类型 |
描述 |
|
|
更新后的节点。 |
|
使用 Cypher 删除属性
无需使用 APOC,即可在 Cypher 中动态引用属性。
用于从节点或关系中动态删除属性的 Cypher 语法
REMOVE n[key]
动态计算的键必须求值为 STRING 值。有关详细信息,请参阅 Cypher 手册 → 动态删除属性。
用法示例
本节中的示例基于以下示例图
CREATE (jennifer:Person {name: "Jennifer", community: 1, partition: 4})
CREATE (karin:Person {name: "Karin", community: 4, partition: 2})
CREATE (elaine:Person {name: "Elaine", community: 3, partition: 3})
MERGE (jennifer)-[:FRIENDS {since: datetime("2019-06-01")}]-(karin)
MERGE (jennifer)-[:FRIENDS {since: datetime("2019-05-04")}]-(elaine);
我们可以通过结合使用 APOC 和 Cypher,从 Person 节点中删除除 name 以外的所有属性
apoc.create.removeProperties
CALL db.propertyKeys()
YIELD propertyKey WHERE propertyKey <> "name"
WITH collect(propertyKey) AS propertyKeys
MATCH (p:Person)
WITH collect(p) AS nodes, propertyKeys
CALL apoc.create.removeProperties(nodes, propertyKeys)
YIELD node
RETURN node;
使用 Cypher 的动态属性
CALL db.propertyKeys()
YIELD propertyKey WHERE propertyKey <> "name"
WITH collect(propertyKey) AS propertyKeys
MATCH (p:Person)
FOREACH (key IN propertyKeys | REMOVE p[key])
RETURN DISTINCT p
| 节点 |
|---|
(:Person {name: "Jennifer"}) |
(:Person {name: "Karin"}) |
(:Person {name: "Elaine"}) |