JSON.NUMPOWBY

JSON.NUMPOWBY key path value
Available in:
Redis Open Source / JSON 2.0.0
Time complexity:
O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key
ACL categories:
@json, @write, @slow,
Compatibility:
Redis Software and Redis Cloud compatibility

Raise the number value stored at path to the power of value

Examples

Required arguments

key

is key to modify.

path

is JSONPath to specify.

value

is number value to use as the exponent.

Examples

redis> JSON.SET doc . '{"a":"b","b":[{"a":2}, {"a":5}, {"a":"c"}]}'
OK
redis> JSON.NUMPOWBY doc $.a 2
"[null]"
redis> JSON.NUMPOWBY doc $..a 2
"[null,4,25,null]"

Details

If both the stored value and value are integers, the result is an integer. It must fit in a 64-bit signed integer, or the command fails with a numeric overflow error.

A negative integer exponent with an integer stored value also fails with numeric overflow. To get a fractional result, write the exponent as a floating-point number: raising 2 to -1.0 returns 0.5.

If either number is a floating-point number, the command uses floating-point arithmetic. A result that isn't a finite real number, such as 0 raised to -1.0 or -8 raised to 0.5, fails with a result is not a number error.

When the command fails, the stored value doesn't change.

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
✅ Supported
✅ Flexible & Annual
✅ Free & Fixed

Return information

With $-based path argument: Bulk string reply containing a JSON array with one element per matching path: the new value, or null if the matching value is not a number. The array is empty if no path matches.

With .-based path argument: Bulk string reply representing the stringified new value. If the path matches more than one number, the command updates all of them and returns the last new value. Simple error reply if no matching value is a number.

With either path argument: simple error reply if the key doesn't exist or the result is out of range.

See also

JSON.NUMINCRBY | JSON.NUMMULTBY

RATE THIS PAGE
Back to top ↑