Skip to content

Commit 68f0200

Browse files
Documentation of json.mset.md (RedisJSON#999)
* Documentation of json.mset.md Command reference details of the new JSON.MSET * Update json.mset.md after comments * solving required arguments
1 parent 6002066 commit 68f0200

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

docs/commands/json.mset.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,58 @@
1-
Sets or updates the JSON value of one or more keys.
1+
Set or update one or more JSON values according to the specified `key`-`path`-`value` triplets
2+
3+
`JSON.MSET` is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to see that some of the keys were updated while others are unchanged.
4+
5+
A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected.
6+
7+
8+
[Examples](#examples)
9+
10+
## Required arguments
11+
12+
<details open><summary><code>key</code></summary>
13+
14+
is key to modify.
15+
</details>
16+
17+
<details open><summary><code>path</code></summary>
18+
19+
is JSONPath to specify. For new Redis keys the `path` must be the root. For existing keys, when the entire `path` exists, the value that it contains is replaced with the `json` value. For existing keys, when the `path` exists, except for the last element, a new child is added with the `json` value.
20+
21+
</details>
22+
23+
<details open><summary><code>value</code></summary>
24+
25+
is value to set at the specified path
26+
</details>
27+
28+
## Return value
29+
30+
JSET.MSET returns a simple string reply: `OK` if executed correctly or `error` if fails to set the new values
31+
32+
For more information about replies, see [Redis serialization protocol specification](/docs/reference/protocol-spec).
33+
34+
## Examples
35+
36+
<details open>
37+
<summary><b>Add a new values in multiple keys</b></summary>
38+
39+
{{< highlight bash >}}
40+
redis> JSON.MSET doc1 $ '{"a":2}' doc2 $.f.a '3' doc3 $ '{"f1": {"a":1}, "f2":{"a":2}}'
41+
OK
42+
redis> JSON.GET doc1 $
43+
"[{\"a\":2}]"
44+
redis> JSON.GET doc2 $
45+
"[{\"f\":{\"a\":3]"
46+
redis> JSON.GET doc3
47+
"{\"f1\":{\"a\":3},\"f2\":{\"a\":3}}"
48+
{{< / highlight >}}
49+
</details>
50+
51+
## See also
52+
53+
`JSON.SET` | `JSON.MGET` | `JSON.GET`
54+
55+
## Related topics
56+
57+
* [RedisJSON](/docs/stack/json)
58+
* [Index and search JSON documents](/docs/stack/search/indexing_json)

0 commit comments

Comments
 (0)