Skip to content

Commit

Permalink
document the remove clause (#101)
Browse files Browse the repository at this point in the history
* document the remove clause

* added the REMOVE clause
  • Loading branch information
swilly22 authored Dec 9, 2024
1 parent 5570e08 commit 165e935
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
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 |


## 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"|[] |

0 comments on commit 165e935

Please sign in to comment.