> For the complete documentation index, see [llms.txt](https://aiii-mike.gitbook.io/redis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aiii-mike.gitbook.io/redis/command/hash/hincrby.md).

# hincrby

### 1. 基本語法

#### (1) hincrby(**`hkey`,  `subkey` ,`increment:<integer>`,`callback`)**&#x20;

&#x82E5;**`hkey`** 以&#x53CA;**`subkey`**&#x5B58;在，且對應資料的字符串內容&#x70BA;**「整數」**&#x5F62;式，則該整數值增&#x52A0;**`increment`**&#x55AE;位。

#### (2) hincrbyfloat(**`hkey`,  `subkey` ,`increment:<number>`,`callback`)**&#x20;

&#x82E5;**`hkey`** 以&#x53CA;**`subkey`**&#x5B58;在，且對應資料的字符串內容&#x70BA;**「整數」或「浮點數」**&#x5F62;式，則該數字值增&#x52A0;**`increment`**&#x55AE;位。

{% tabs %}
{% tab title="TypeScript" %}

```typescript
const dict = { 
    name: 'Mufasa', 
    gender: 'M', 
    age: '38',
    offspring : '2'
};


client.hmset('user:6', dict);
client.hgetall('user:6', (err, obj) => {
    console.log(obj);
});


client.hincrby('user:6', 'offspring', -1);
client.hincrby('user:6', 'age', 2, (err, numAfterIncr) => {
    console.log(numAfterIncr);
});


client.hgetall('user:6', (err, obj) => {
    console.log(obj);
})

```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Output-TS" %}

```
{ name: 'Mufasa', gender: 'M', age: '38', offspring: '2' }
40
{ name: 'Mufasa', gender: 'M', age: '40', offspring: '1' }
```

{% endtab %}
{% endtabs %}
