> For the complete documentation index, see [llms.txt](https://simpldb.js.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simpldb.js.org/v1/documentation/database/save.md).

# .save()

Writes the cached data into the JSON file (database).

{% hint style="info" %}
This method must be used if you set **`saveOnUpdate`** to `false` when creating the database, otherwise you should not use it.
{% endhint %}

### save()

```javascript
db.toJSON(); // { counter: 17 }

db.add('counter', 3); // 17

db.get('counter'); // 17

db.save();

db.get('counter'); // 20
```
