From be78df53a99f0b3c0bb4cea357d5cbfc7d624fbc Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Fri, 24 Jan 2025 21:49:53 +0200 Subject: [PATCH 1/6] JSON.SET - clarify return value; more examples --- content/commands/json.set/index.md | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index d78d4c5d0f..c4a5c7a2bf 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -79,7 +79,11 @@ sets the key only if it already exists. ## Return value -JSET.SET returns a simple string reply: `OK` if executed correctly or `nil` if the specified `NX` or `XX` conditions were not met. +Returns one of these replies: +- A simple string reply: `OK` if executed correctly +- `nil` - if `path` does not exist and cannot be created, or if the specified `NX` or `XX` conditions were unmet +- error if `key` does not exist and `path` is not root + For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}). ## Examples @@ -123,6 +127,38 @@ redis> JSON.GET doc {{< / highlight >}} +
+path does not exist and cannot be created + +{{< highlight bash >}} +redis> JSON.SET doc $ 1 +OK +redis> JSON.SET doc $.x.y 2 +(nil) +{{< / highlight >}} +
+ +
+XX condition unmet + +{{< highlight bash >}} +redis> JSON.SET nonexistentkey $ 5 XX +(nil) +redis> JSON.GET nonexistentkey +(nil) +{{< / highlight >}} +
+ +
+key does not exist and path is not root + +{{< highlight bash >}} +redis> JSON.SET nonexistentkey $.x 5 +(error) ERR new objects must be created at the root +{{< / highlight >}} +
+ + ## See also [`JSON.GET`]({{< baseurl >}}/commands/json.get/) | [`JSON.MGET`]({{< baseurl >}}/commands/json.mget/) From c2389b7144462e78af56807cc9c10a36afb62ce5 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Fri, 24 Jan 2025 21:54:31 +0200 Subject: [PATCH 2/6] Update index.md --- content/commands/json.set/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index c4a5c7a2bf..84819d8f00 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -81,7 +81,9 @@ sets the key only if it already exists. Returns one of these replies: - A simple string reply: `OK` if executed correctly -- `nil` - if `path` does not exist and cannot be created, or if the specified `NX` or `XX` conditions were unmet +- `nil` + - if `key` exists but `path` does not exist and cannot be created + - if a specified `NX` or `XX` condition were unmet - error if `key` does not exist and `path` is not root For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}). From f6cffadc99654a1060486f65ca00cadbe5433d13 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Fri, 24 Jan 2025 21:54:55 +0200 Subject: [PATCH 3/6] Update index.md --- content/commands/json.set/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index 84819d8f00..4503386cd8 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -83,7 +83,7 @@ Returns one of these replies: - A simple string reply: `OK` if executed correctly - `nil` - if `key` exists but `path` does not exist and cannot be created - - if a specified `NX` or `XX` condition were unmet + - if a specified `NX` or `XX` condition was unmet - error if `key` does not exist and `path` is not root For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}). From c33f45cbb1f7d8b493cdea23a716298797c19138 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Fri, 24 Jan 2025 21:55:26 +0200 Subject: [PATCH 4/6] Update index.md --- content/commands/json.set/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index 4503386cd8..b5ac22b96f 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -83,7 +83,7 @@ Returns one of these replies: - A simple string reply: `OK` if executed correctly - `nil` - if `key` exists but `path` does not exist and cannot be created - - if a specified `NX` or `XX` condition was unmet + - if an `NX` or `XX` condition was unmet - error if `key` does not exist and `path` is not root For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}). From ab32e8c7a9911b07764d0becaee49ba6a0bfb46e Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Fri, 24 Jan 2025 21:58:18 +0200 Subject: [PATCH 5/6] Update index.md --- content/commands/json.set/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index b5ac22b96f..545e0a9c1c 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -84,7 +84,7 @@ Returns one of these replies: - `nil` - if `key` exists but `path` does not exist and cannot be created - if an `NX` or `XX` condition was unmet -- error if `key` does not exist and `path` is not root +- error if `key` does not exist and `path` is not root (`.` or `$`) For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}). From b2b7b77b767ca20bb958e66fb0097eca72e1596c Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Fri, 24 Jan 2025 21:59:49 +0200 Subject: [PATCH 6/6] Update index.md --- content/commands/json.set/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index 545e0a9c1c..1b89a9993d 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -83,7 +83,7 @@ Returns one of these replies: - A simple string reply: `OK` if executed correctly - `nil` - if `key` exists but `path` does not exist and cannot be created - - if an `NX` or `XX` condition was unmet + - if an `NX` or `XX` condition is unmet - error if `key` does not exist and `path` is not root (`.` or `$`) For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).