-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document the remove clause #101
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
title: "REMOVE" | ||
nav_order: 22 | ||
description: > | ||
REMOVE is used to remove attributes from node and relationships, in addition to | ||
removing labels from nodes. | ||
parent: "Cypher Language" | ||
--- | ||
|
||
# REMOVE | ||
|
||
## Example graph | ||
|
||
```cypher | ||
CREATE | ||
(billy :Player {name: 'Billy', score: 84}), | ||
(andy :Player {name: 'Andy', score: 21}), | ||
(lori :Player:Admin {name: 'Lori', score: 90}) | ||
``` | ||
|
||
## Remove attributes | ||
|
||
The following query removes the 'score' attribute from the node | ||
representing Andy. | ||
|
||
```cypher | ||
MATCH (n {name: 'Andy'}) | ||
REMOVE n.score | ||
RETURN n.name, n.score | ||
``` | ||
|
||
Result: | ||
|n.name|n.score| | ||
|------|-------| | ||
|"Andy"| Null | | ||
|
||
|
||
## Remove a label from a node | ||
|
||
To remove a label from a node use the REMOVE clause as follows: | ||
|
||
```cypher | ||
MATCH (n {name: 'Lori'}) | ||
REMOVE n:Admin | ||
RETURN n.name, labels(n) | ||
``` | ||
|
||
Result: | ||
|n.name|abels(n)| | ||
|------|--------| | ||
|"Lori"|[Player]| | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo and add important notes about label removal.
## Remove a label from a node
To remove a label from a node use the REMOVE clause as follows:
+
+Note: Attempting to remove a non-existent label from a node is a no-op operation
+and will not cause an error.
```cypher
MATCH (n {name: 'Lori'})
REMOVE n:Admin
RETURN n.name, labels(n) Result:
|
||
|
||
## Removing multiple labels from a node | ||
|
||
Similar to removing a single label from a node we can use the REMOVE clause | ||
to remove multiple labels in one go | ||
|
||
```cypher | ||
MATCH (n :Player {name: 'Lori'}) | ||
REMOVE n:Admin:Player | ||
RETURN n.name, labels(n) | ||
``` | ||
|
||
Result: | ||
|n.name|abels(n)| | ||
|------|--------| | ||
|"Lori"|[] | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo and add clarification about multiple label removal.
## Removing multiple labels from a node
Similar to removing a single label from a node we can use the REMOVE clause
-to remove multiple labels in one go
+to remove multiple labels in one go. The order of labels in the REMOVE clause
+does not matter.
```cypher
MATCH (n :Player {name: 'Lori'})
REMOVE n:Admin:Player
RETURN n.name, labels(n) Result:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add missing examples and fix table formatting.
The section should include:
Result:
+
+### Remove relationship properties
+
+The following query removes the 'since' property from KNOWS relationships:
+
+
cypher +MATCH (lori {name: 'Lori'})-[r:KNOWS]->(bob) +REMOVE r.since +RETURN type(r), r.since +
+
+Result:
+
+|type(r)|r.since|
+|-------|-------|
+|"KNOWS"| Null |
+
+### Remove multiple properties
+
+You can remove multiple properties in a single REMOVE clause:
+
+
cypher +MATCH (n {name: 'Billy'}) +REMOVE n.score, n.name +RETURN n +