Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

JSON.NUMINCRBY

Focus mode
JSON.NUMINCRBY - Amazon MemoryDB

Increment the number values at the path by a given number.

Syntax

JSON.NUMINCRBY <key> <path> <number>
  • key (required) – key of JSON document type

  • path (required) – a JSON path

  • number (required) – a number

Return

If the path is enhanced syntax:

  • Array of bulk Strings representing the resulting value at each path.

  • If a value is not a number, its corresponding return value is null.

  • WRONGTYPE error if the number cannot be parsed.

  • OVERFLOW error if the result is out of the range of 64-bit IEEE double.

  • NONEXISTENT if the document key does not exist.

If the path is restricted syntax:

  • Bulk String representing the resulting value.

  • If multiple values are selected, the command returns the result of the last updated value.

  • WRONGTYPE error if the value at the path is not a number.

  • WRONGTYPE error if the number cannot be parsed.

  • OVERFLOW error if the result is out of the range of 64-bit IEEE double.

  • NONEXISTENT if the document key does not exist.

Examples

Enhanced path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMINCRBY k1 $.d[*] 10 "[11,12,13]" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[1],\"c\":[1,2],\"d\":[11,12,13]}" 127.0.0.1:6379> JSON.SET k1 $ '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMINCRBY k1 $.a[*] 1 "[]" 127.0.0.1:6379> JSON.NUMINCRBY k1 $.b[*] 1 "[2]" 127.0.0.1:6379> JSON.NUMINCRBY k1 $.c[*] 1 "[2,3]" 127.0.0.1:6379> JSON.NUMINCRBY k1 $.d[*] 1 "[2,3,4]" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[2,3],\"d\":[2,3,4]}" 127.0.0.1:6379> JSON.SET k2 $ '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}, "d":{"a":1, "b":2, "c":3}}' OK 127.0.0.1:6379> JSON.NUMINCRBY k2 $.a.* 1 "[]" 127.0.0.1:6379> JSON.NUMINCRBY k2 $.b.* 1 "[2]" 127.0.0.1:6379> JSON.NUMINCRBY k2 $.c.* 1 "[2,3]" 127.0.0.1:6379> JSON.NUMINCRBY k2 $.d.* 1 "[2,3,4]" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":2,\"b\":3},\"d\":{\"a\":2,\"b\":3,\"c\":4}}" 127.0.0.1:6379> JSON.SET k3 $ '{"a":{"a":"a"}, "b":{"a":"a", "b":1}, "c":{"a":"a", "b":"b"}, "d":{"a":1, "b":"b", "c":3}}' OK 127.0.0.1:6379> JSON.NUMINCRBY k3 $.a.* 1 "[null]" 127.0.0.1:6379> JSON.NUMINCRBY k3 $.b.* 1 "[null,2]" 127.0.0.1:6379> JSON.NUMINCRBY k3 $.c.* 1 "[null,null]" 127.0.0.1:6379> JSON.NUMINCRBY k3 $.d.* 1 "[2,null,4]" 127.0.0.1:6379> JSON.GET k3 "{\"a\":{\"a\":\"a\"},\"b\":{\"a\":\"a\",\"b\":2},\"c\":{\"a\":\"a\",\"b\":\"b\"},\"d\":{\"a\":2,\"b\":\"b\",\"c\":4}}"

Restricted path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMINCRBY k1 .d[1] 10 "12" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[1],\"c\":[1,2],\"d\":[1,12,3]}" 127.0.0.1:6379> JSON.SET k1 . '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMINCRBY k1 .a[*] 1 (error) NONEXISTENT JSON path does not exist 127.0.0.1:6379> JSON.NUMINCRBY k1 .b[*] 1 "2" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[1,2],\"d\":[1,2,3]}" 127.0.0.1:6379> JSON.NUMINCRBY k1 .c[*] 1 "3" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[2,3],\"d\":[1,2,3]}" 127.0.0.1:6379> JSON.NUMINCRBY k1 .d[*] 1 "4" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[2,3],\"d\":[2,3,4]}" 127.0.0.1:6379> JSON.SET k2 . '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}, "d":{"a":1, "b":2, "c":3}}' OK 127.0.0.1:6379> JSON.NUMINCRBY k2 .a.* 1 (error) NONEXISTENT JSON path does not exist 127.0.0.1:6379> JSON.NUMINCRBY k2 .b.* 1 "2" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":1,\"b\":2},\"d\":{\"a\":1,\"b\":2,\"c\":3}}" 127.0.0.1:6379> JSON.NUMINCRBY k2 .c.* 1 "3" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":2,\"b\":3},\"d\":{\"a\":1,\"b\":2,\"c\":3}}" 127.0.0.1:6379> JSON.NUMINCRBY k2 .d.* 1 "4" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":2,\"b\":3},\"d\":{\"a\":2,\"b\":3,\"c\":4}}" 127.0.0.1:6379> JSON.SET k3 . '{"a":{"a":"a"}, "b":{"a":"a", "b":1}, "c":{"a":"a", "b":"b"}, "d":{"a":1, "b":"b", "c":3}}' OK 127.0.0.1:6379> JSON.NUMINCRBY k3 .a.* 1 (error) WRONGTYPE JSON element is not a number 127.0.0.1:6379> JSON.NUMINCRBY k3 .b.* 1 "2" 127.0.0.1:6379> JSON.NUMINCRBY k3 .c.* 1 (error) WRONGTYPE JSON element is not a number 127.0.0.1:6379> JSON.NUMINCRBY k3 .d.* 1 "4"
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.