Skip to content

Commit 93970c7

Browse files
Update arrays.md
1 parent 0469357 commit 93970c7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ds/json/arrays.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Redis has several commands that allow you to manipulate JSON arrays. Simple documents will be used to demonstrate each command.
22

3-
```redis Create a document
3+
```redis:[run_confirmation=true] Create a document
44
JSON.SET doc $ '{"a": [10, 20, 30, 40, 50]}'
55
```
66

@@ -12,14 +12,14 @@ JSON.ARRLEN doc $.a
1212

1313
- `JSON.ARRAPPEND` - append one or more values to an array:
1414

15-
```redis Append two values to $.a
15+
```redis:[run_confirmation=true] Append two values to $.a
1616
JSON.ARRAPPEND doc $.a 60 '"foo"'
1717
JSON.GET doc $.a
1818
```
1919

2020
- `JSON.ARRPOP` - remove an element from an array:
2121

22-
```redis Remove the last item from $.a
22+
```redis:[run_confirmation=true] Remove the last item from $.a
2323
JSON.ARRPOP doc $.a
2424
JSON.GET doc $.a
2525
```
@@ -30,25 +30,25 @@ For example, `-1` mean the last element and `-2` means the second to last elemen
3030

3131
- `JSON.ARRTRIM` - trim an array so that it contains only the specified inclusive range of elements.
3232

33-
```redis Trim $.a to just the first 3 elements
33+
```redis:[run_confirmation=true] Trim $.a to just the first 3 elements
3434
JSON.ARRTRIM doc $.a 0 2
3535
JSON.GET doc
3636
```
3737

3838
Now, reset doc to it's original value and trim `$.a` to just the last two values:
3939

40-
```redis Re-create the document
40+
```redis:[run_confirmation=true] Re-create the document
4141
JSON.SET doc $ '{"a": [10, 20, 30, 40, 50]}'
4242
```
4343

44-
```redis Trim to the last two values
44+
```redis:[run_confirmation=true] Trim to the last two values
4545
JSON.ARRTRIM doc $.a -2 -1
4646
JSON.GET doc
4747
```
4848

4949
As discussed earlier in this tutorial, `JSON.MERGE` can be used to replace entire arrays.
5050

51-
```redis Replace $.a with a different set of values
51+
```redis:[run_confirmation=true] Replace $.a with a different set of values
5252
JSON.MERGE doc $.a '["a", "b", "c"]'
5353
JSON.GET doc
54-
```
54+
```

0 commit comments

Comments
 (0)