.save()

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

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

Was this helpful?