File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed
content/commands/json.set Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,13 @@ sets the key only if it already exists.
79
79
80
80
## Return value
81
81
82
- JSET.SET returns a simple string reply: ` OK ` if executed correctly or ` nil ` if the specified ` NX ` or ` XX ` conditions were not met.
82
+ Returns one of these replies:
83
+ - A simple string reply: ` OK ` if executed correctly
84
+ - ` nil `
85
+ - if ` key ` exists but ` path ` does not exist and cannot be created
86
+ - if an ` NX ` or ` XX ` condition is unmet
87
+ - error if ` key ` does not exist and ` path ` is not root (` . ` or ` $ ` )
88
+
83
89
For more information about replies, see [ Redis serialization protocol specification] ({{< relref "/develop/reference/protocol-spec" >}}).
84
90
85
91
## Examples
@@ -123,6 +129,38 @@ redis> JSON.GET doc
123
129
{{< / highlight >}}
124
130
</details >
125
131
132
+ <details open >
133
+ <summary ><b >path does not exist and cannot be created</b ></summary >
134
+
135
+ {{< highlight bash >}}
136
+ redis> JSON.SET doc $ 1
137
+ OK
138
+ redis> JSON.SET doc $.x.y 2
139
+ (nil)
140
+ {{< / highlight >}}
141
+ </details >
142
+
143
+ <details open >
144
+ <summary ><b >XX condition unmet</b ></summary >
145
+
146
+ {{< highlight bash >}}
147
+ redis> JSON.SET nonexistentkey $ 5 XX
148
+ (nil)
149
+ redis> JSON.GET nonexistentkey
150
+ (nil)
151
+ {{< / highlight >}}
152
+ </details >
153
+
154
+ <details open >
155
+ <summary ><b >key does not exist and path is not root</b ></summary >
156
+
157
+ {{< highlight bash >}}
158
+ redis> JSON.SET nonexistentkey $.x 5
159
+ (error) ERR new objects must be created at the root
160
+ {{< / highlight >}}
161
+ </details >
162
+
163
+
126
164
## See also
127
165
128
166
[ ` JSON.GET ` ] ({{< baseurl >}}/commands/json.get/) | [ ` JSON.MGET ` ] ({{< baseurl >}}/commands/json.mget/)
You can’t perform that action at this time.
0 commit comments