Skip to content
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

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cypher/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Cypher query consists of one or more clauses
* [CREATE](/cypher/create)
* [MERGE](/cypher/merge)
* [DELETE](/cypher/delete)
* [REMOVE](/cypher/remove)
* [SET](/cypher/set)
* [WITH](/cypher/with)
* [UNION](/cypher/union)
Expand All @@ -41,4 +42,4 @@ See list of available graph [Algorithms](/cypher/algorithms)

# Indexing

See how to utilize [Indexing](/cypher/indexing)
See how to utilize [Indexing](/cypher/indexing)
68 changes: 68 additions & 0 deletions cypher/remove.md
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 |

Comment on lines +21 to +36
Copy link
Contributor

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:

  1. Example of removing relationship properties
  2. Example of removing multiple properties at once
  3. Proper table formatting with surrounding blank lines
 ## Remove attributes

+### Remove node properties
+
 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 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 +


<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Markdownlint (0.35.0)</summary>

33-33: null
Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit -->


## 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|labels(n)|
|------|--------|
|"Lori"|[Player]|


## 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|labels(n)|
|------|--------|
|"Lori"|[] |
Loading