Skip to content

Commit 3e8025e

Browse files
Update modify.md
1 parent cb87b23 commit 3e8025e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/ds/json/modify.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ Here are some examples.
44

55
## Extend documents
66

7-
```redis Add a new name-value pair to an existing document
7+
```redis:[run_confirmation=true] Add a new name-value pair to an existing document
88
JSON.SET bicycle:1 $.newmember '"value"'
99
```
1010

1111
You could also use `JSON.MSET` to create or update multiple documents at the same time. First, delete `$.newmember` from `bicycle:1` using `JSON.DEL`.
1212

13-
```redis Delete $.newmember from bicycle:1
13+
```redis:[run_confirmation=true] Delete $.newmember from bicycle:1
1414
JSON.DEL bicycle:1 $.newmember
1515
```
1616

1717
Next, add `$.newmember` to all three bicycles:
1818

19-
```redis Add a member named newmember too all three bicycles using JSON.MSET
19+
```redis:[run_confirmation=true] Add a member named newmember too all three bicycles using JSON.MSET
2020
JSON.MSET bicycle:1 $.newmember '"value1"' bicycle:2 $.newmember '"value2"' bicycle:3 $.newmember '"value3"'
2121
JSON.MGET bicycle:1 bicycle:2 bicycle:3 $.newmember
2222
```
@@ -26,7 +26,7 @@ JSON.MGET bicycle:1 bicycle:2 bicycle:3 $.newmember
2626
The `JSON.NUMINCRBY` command allows you to perform arithmetic operations on numeric fields of documents.
2727
Use positive numbers to increment and negative numbers to decrement.
2828

29-
```redis Decrease the price of bicycle:1
29+
```redis:[run_confirmation=true] Decrease the price of bicycle:1
3030
JSON.GET bicycle:1 $.price
3131
JSON.NUMINCRBY bicycle:1 $.price -10
3232
JSON.GET bicycle:1 $.price
@@ -35,14 +35,14 @@ JSON.GET bicycle:1 $.price
3535

3636
Appending information to JSON strings is straightforward.
3737

38-
```redis Append a string bicycle:1's model
38+
```redis:[run_confirmation=true] Append a string bicycle:1's model
3939
JSON.STRAPPEND bicycle:1 $.model '"naut"'
4040
JSON.GET bicycle:1 $.model
4141
```
4242

4343
The `JSON.TOGGLE` command can be used to toggle boolean values.
4444

45-
```redis Toggle the value of bicycle:1's helmet_included value
45+
```redis:[run_confirmation=true] Toggle the value of bicycle:1's helmet_included value
4646
JSON.GET bicycle:1 $.helmet_included
4747
JSON.TOGGLE bicycle:1 $.helmet_included
4848
JSON.GET bicycle:1 $.helmet_included
@@ -54,28 +54,28 @@ As you saw earlier, the `JSON.MERGE` command can be used to create new documents
5454

5555
- Create a non-existant path-value:
5656

57-
```redis Add a new name-value pair to bicycle:1
57+
```redis:[run_confirmation=true] Add a new name-value pair to bicycle:1
5858
JSON.MERGE bicycle:1 $.newmember2 '"value 2 1"'
5959
JSON.GET bicycle:1
6060
```
6161

6262
- Replace an existing value:
6363

64-
```redis Change bicycle:1's model back to Jigger
64+
```redis:[run_confirmation=true] Change bicycle:1's model back to Jigger
6565
JSON.MERGE bicycle:1 $.model '"Jigger"'
6666
JSON.GET bicycle:1 $.model
6767
```
6868

6969
- Delete an existing value:
7070

71-
```redis Delete newmember2 from bicycle:1
71+
```redis:[run_confirmation=true] Delete newmember2 from bicycle:1
7272
JSON.MERGE bicycle:1 $ '{"newmember2": null}'
7373
JSON.GET bicycle:1
7474
```
7575

7676
- Replace an array:
7777

78-
```redis Replace bicycle:1's addons
78+
```redis:[run_confirmation=true] Replace bicycle:1's addons
7979
JSON.MERGE bicycle:1 $.addons '["reflectors", "rainbow seat"]'
8080
JSON.GET bicycle:1 $.addons
8181
```
@@ -86,17 +86,17 @@ JSON.GET bicycle:1 $.addons
8686

8787
You can delete name-value pairs using the `JSON.DEL` or `JSON.FORGET` commands:
8888

89-
```redis Delete newmember from bicycle:1
89+
```redis:[run_confirmation=true] Delete newmember from bicycle:1
9090
JSON.DEL bicycle:1 $.newmember
9191
JSON.GET bicycle:1
9292
```
9393

9494
The `JSON.CLEAR` command will empty all arrays and set all numeric values to zero. A simple example will illustrate how this works.
9595

96-
```redis JSON.CLEAR usage
96+
```redis:[run_confirmation=true] JSON.CLEAR usage
9797
JSON.SET doc $ '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14}'
9898
JSON.CLEAR doc $.*
9999
JSON.GET doc $
100100
```
101101

102-
As with all Redis keys, you can use the `DEL` command to delete keys entirely.
102+
As with all Redis keys, you can use the `DEL` command to delete keys entirely.

0 commit comments

Comments
 (0)