await redis.set("key", 6);
await redis.decrby("key", 4);
// returns 2

If a key does not exist, it is initialized as 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer.

Arguments

key
string
required

The key to decrement.

decrementBy
integer
required

The amount to decrement by.

Response

The value at the key after the decrementing.

Was this page helpful?