Upstash Documentation

JSON.NUMMULTBY

Multiply JSON number.
2 min read

Use JSON.NUMMULTBY to multiply the numeric values a path selects by a number.

The multiplier may be a fraction to scale values down, and the update is atomic. The reply is the new value of each match, and a match that is not a number returns an error. It is the multiplicative counterpart of JSON.NUMINCRBY, useful for applying percentage changes such as a discount to every price in a document.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
keyYesNoJSON document key.
pathYesNoPath selecting numbers.
valueYesNoNumeric multiplier.

Important points#

  • Raw TCP examples pass JSON values as valid JSON text. Typed Upstash SDK helpers serialize native objects and values for you.
  • Paths beginning with $ use JSONPath and can match multiple values, so many JSON commands return an array of per-match results.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Bulk string containing a JSON number or array
RESP3Bulk string containing a JSON number or array
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs