> 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/documentation/database/save.md).

# .save()

Writes the cached data into the JSON file.

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

### save()

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

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

db.get('counter'); // 20 (cached only)
db.fetch('counter'); // 17

db.save();

db.get('counter'); // 20 (cached and written in the JSON file)
db.fetch('counter'); // 20
```
