Proposal: ApplicationAdapter.clear()

After playing around with the Ember Data Factory, I realized that ember-data has today no convenient way to reset the adapter (or better the storage behind the adapter). To have a rspec / factory-girl like behavior with Ember Data Factory, I would propose an ApplicationAdapter.reset() method (like App.reset()) to reset the storage behind an adapter.

For the FIXTUREAdapater this could reset all fixtures:

App.__container__.lookup('dataAdapter:main')
.getModelTypes().forEach(function(type) {
  type.FIXTURES = [];
});

some adapters could provide the same behavior also out of the box (localStorage.clear(), etc.), others could allow to overwrite the reset function with an own implementation like teddyzeenny: https://github.com/teddyzeenny/ember-data-factory/issues/4#issuecomment-26702456

What do you think?

I would expect #reset to reload the data as it was when the page was loaded. What you’re describing would be #clear.

1 Like

I agree that it would be useful to have a helper method that would unload all the locally stored records.

Relevant issue: https://github.com/emberjs/data/issues/235

Not really, this thread is about clearing (yes clear is better) the store behind the ember-data store (so your database, fixtures, etc.) instead of just unloading all records from ember-data.