> 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/v2.11.0/documentation/collection/save.md).

# .save()

Writes the cached data into the collection's 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
// Note: Users is a collection.

Users.get(); // [{ id: 1, name: 'Peter' }]

Users.create({ id: 2, name: 'Michael' }); // { id: 2, name: 'Michael' }

Users.get(); // [{ id: 1, name: 'Peter' }, { id: 2, name: 'Michael' }] (cached only)
Users.fetch(); // [{ id: 1, name: 'Peter' }]

Users.save();

Users.get(); // [{ id: 1, name: 'Peter' }, { id: 2, name: 'Michael' }] (cached and written in the JSON file)  
Users.fetch(); // [{ id: 1, name: 'Peter' }, { id: 2, name: 'Michael' }]
```
