.save()

Writes the cached data into the collection's JSON file.

This method must be used if you set autoSave to false when creating the database, otherwise you should not use it.

save()

// Note: Users is a collection.

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

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

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

Users.save();

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

Last updated