locks / ember-localstorage-adapter

Name says it all.
MIT License
466 stars 156 forks source link

Unable to fetch with .findAll('user') #220

Closed janwerkhoven closed 7 years ago

janwerkhoven commented 7 years ago

So on .save() records are successfully persisted to the localstorage. I seem unable to retrieve them after having refreshed the page. Doing this.store.findAll('user').mapBy('name') keeps returning [].

What am I forgetting?

// app/adapters/application.js
import LSAdapter from 'ember-localstorage-adapter';
export default LSAdapter.extend({
  namespace: 'test'
});
app/serializers/application.js
import { LSSerializer } from 'ember-localstorage-adapter';
export default LSSerializer.extend();
// app/routes/test.js
export default Ember.Route.extend({
  beforeModel(transition) {
    this.store.findAll('user'); // Returns []
  }
});
// app/models/user.js
export default Model.extend({
  name: attr('string')
});
// package.json
{
  ...
  "devDependencies": {
    "ember-cli": "2.13.2",
    "ember-data": "^2.13.0",
    "ember-localstorage-adapter": "^1.0.0",
    ...
  },
  ...
}
janwerkhoven commented 7 years ago

Oh, shame on me. It's a promise, of course it won't work calling this.store.findAll('transaction') in a debugger;. The example below works like a charm, thanks!

  model() {
    return this.store.findAll('user');
  },
  afterModel(model) {
    debugger;
  }