Increments the numeric value at the specified path by a given amount. Supports both integers and floating-point numbers.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/upstash/redis-js/llms.txt
Use this file to discover all available pages before exploring further.
Usage
Arguments
The key containing the JSON document
JSONPath expression pointing to the numeric value to increment
The increment value. Can be positive (to increase) or negative (to decrease). Supports both integers and floating-point numbers.
Response
An array of numbers representing the new value at each matching path after the increment. Returns
null for paths that don’t exist or aren’t numeric values.Examples
Increment an integer
Decrement by using negative value
Increment a floating-point number
Increment nested numeric value
Increment multiple values (wildcard path)
Increment with decimal precision
Track counter
Handle non-existent paths
Handle non-numeric values
JSONPath Syntax
$.number- Increment a top-level number$.nested.number- Increment a nested number$.object.count- Increment a number within an object$..count- Increment all matching numbers recursively$.items[*].quantity- Increment numbers within each item
Notes
- The operation is atomic - the increment happens as a single operation
- Both integers and floating-point numbers are supported
- Negative values can be used to decrement
- Returns
nullif the path doesn’t exist or doesn’t point to a numeric value - When using wildcard paths, the operation is performed on all matching numeric values
- Floating-point arithmetic follows standard IEEE 754 rules
See Also
- JSON.SET - Set JSON values
- JSON.GET - Get JSON values
- Redis JSON.NUMINCRBY documentation