# .subtract()

### subtract(key, value)

| **Parameter** | **Description**                                                                                                                                                        |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| key           | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></p><p>The key that will have its value decremented</p> |
| value         | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></p><p>The value to decrement</p>                       |

| **Returns**                                                                                                                                                                    | **Description**                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
| [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [JSONData](https://simpldb.gitbook.io/docs/types-and-interfaces/jsondata) | The updated data from the provided key's root |

####

```javascript
db.get('balance'); // 350

db.subtract('balance', 100); // 250
```

Also allows the use of dot notation:

```javascript
db.get('account'); // { owner: '5antos', balance: 800 }

db.subtract('account.balance', 200); // { owner: '5antos', balance: 600 }
```
