@@ -4,19 +4,19 @@ Here are some examples.
4
4
5
5
## Extend documents
6
6
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
8
8
JSON.SET bicycle:1 $.newmember '"value"'
9
9
```
10
10
11
11
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 ` .
12
12
13
- ``` redis Delete $.newmember from bicycle:1
13
+ ``` redis:[run_confirmation=true] Delete $.newmember from bicycle:1
14
14
JSON.DEL bicycle:1 $.newmember
15
15
```
16
16
17
17
Next, add ` $.newmember ` to all three bicycles:
18
18
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
20
20
JSON.MSET bicycle:1 $.newmember '"value1"' bicycle:2 $.newmember '"value2"' bicycle:3 $.newmember '"value3"'
21
21
JSON.MGET bicycle:1 bicycle:2 bicycle:3 $.newmember
22
22
```
@@ -26,7 +26,7 @@ JSON.MGET bicycle:1 bicycle:2 bicycle:3 $.newmember
26
26
The ` JSON.NUMINCRBY ` command allows you to perform arithmetic operations on numeric fields of documents.
27
27
Use positive numbers to increment and negative numbers to decrement.
28
28
29
- ``` redis Decrease the price of bicycle:1
29
+ ``` redis:[run_confirmation=true] Decrease the price of bicycle:1
30
30
JSON.GET bicycle:1 $.price
31
31
JSON.NUMINCRBY bicycle:1 $.price -10
32
32
JSON.GET bicycle:1 $.price
@@ -35,14 +35,14 @@ JSON.GET bicycle:1 $.price
35
35
36
36
Appending information to JSON strings is straightforward.
37
37
38
- ``` redis Append a string bicycle:1's model
38
+ ``` redis:[run_confirmation=true] Append a string bicycle:1's model
39
39
JSON.STRAPPEND bicycle:1 $.model '"naut"'
40
40
JSON.GET bicycle:1 $.model
41
41
```
42
42
43
43
The ` JSON.TOGGLE ` command can be used to toggle boolean values.
44
44
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
46
46
JSON.GET bicycle:1 $.helmet_included
47
47
JSON.TOGGLE bicycle:1 $.helmet_included
48
48
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
54
54
55
55
- Create a non-existant path-value:
56
56
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
58
58
JSON.MERGE bicycle:1 $.newmember2 '"value 2 1"'
59
59
JSON.GET bicycle:1
60
60
```
61
61
62
62
- Replace an existing value:
63
63
64
- ``` redis Change bicycle:1's model back to Jigger
64
+ ``` redis:[run_confirmation=true] Change bicycle:1's model back to Jigger
65
65
JSON.MERGE bicycle:1 $.model '"Jigger"'
66
66
JSON.GET bicycle:1 $.model
67
67
```
68
68
69
69
- Delete an existing value:
70
70
71
- ``` redis Delete newmember2 from bicycle:1
71
+ ``` redis:[run_confirmation=true] Delete newmember2 from bicycle:1
72
72
JSON.MERGE bicycle:1 $ '{"newmember2": null}'
73
73
JSON.GET bicycle:1
74
74
```
75
75
76
76
- Replace an array:
77
77
78
- ``` redis Replace bicycle:1's addons
78
+ ``` redis:[run_confirmation=true] Replace bicycle:1's addons
79
79
JSON.MERGE bicycle:1 $.addons '["reflectors", "rainbow seat"]'
80
80
JSON.GET bicycle:1 $.addons
81
81
```
@@ -86,17 +86,17 @@ JSON.GET bicycle:1 $.addons
86
86
87
87
You can delete name-value pairs using the ` JSON.DEL ` or ` JSON.FORGET ` commands:
88
88
89
- ``` redis Delete newmember from bicycle:1
89
+ ``` redis:[run_confirmation=true] Delete newmember from bicycle:1
90
90
JSON.DEL bicycle:1 $.newmember
91
91
JSON.GET bicycle:1
92
92
```
93
93
94
94
The ` JSON.CLEAR ` command will empty all arrays and set all numeric values to zero. A simple example will illustrate how this works.
95
95
96
- ``` redis JSON.CLEAR usage
96
+ ``` redis:[run_confirmation=true] JSON.CLEAR usage
97
97
JSON.SET doc $ '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14}'
98
98
JSON.CLEAR doc $.*
99
99
JSON.GET doc $
100
100
```
101
101
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