Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 1.5 KB

json.numincrby.md

File metadata and controls

64 lines (40 loc) · 1.5 KB

Increment the number value stored at path by number

Examples

Required arguments

key

is key to modify.

value

is number value to increment.

Optional arguments

path

is JSONPath to specify. Default is root $.

Return

JSON.NUMINCRBY returns a bulk string reply specified as a stringified new value for each path, or nil, if the matching JSON value is not a number. For more information about replies, see Redis serialization protocol specification.

Examples

Increment number values

Create a document.

{{< highlight bash >}} 127.0.0.1:6379> JSON.SET doc . '{"a":"b","b":[{"a":2}, {"a":5}, {"a":"c"}]}' OK {{< / highlight >}}

Increment a value of a object by 2. The command fails to find a number and returns null.

{{< highlight bash >}} 127.0.0.1:6379> JSON.NUMINCRBY doc $.a 2 "[null]" {{< / highlight >}}

Recursively find and increment a value of all a objects. The command increments numbers it finds and returns null for nonnumber values.

{{< highlight bash >}} 127.0.0.1:6379> JSON.NUMINCRBY doc $..a 2 "[null,4,7,null]" {{< / highlight >}}

See also

JSON.ARRINDEX | JSON.ARRINSERT

Related topics