mardi 28 avril 2015

ember-data: find return nothing in local storage adapter

Ember : 1.11.1

Ember Data : 1.0.0-beta.16.1

jQuery : 1.11.2

"ember-localstorage-adapter": "0.5.3"

I have an issue regarding storage in ember.js

I am able to save records in the storage adapter, but not retrieve them...

create record:

this.store.createRecord('mtgTrail', {name: "foo"}).save()
Class {__ember1430287079605: null, __nextSuper: undefined, __ember_meta__: Object, constructor: function, _super: function…}

find with all:

this.store.all('mtgTrail').forEach(function(trail) { console.log(trail.get('name'))})
foo
Class {type: function, content: (...), store: Class, isLoaded: true, manager: Class…}

find with find:

this.store.find('mtgTrail').then(function(trails) { trails.forEach(function(trail) { console.log(trail.get('name'))})})
Promise {_id: 188, _label: undefined, _state: undefined, _result: undefined, _subscribers: Array[0]…}

content of localstorage:

localStorage.getItem('mantrailling')
"{"mtgTrail":{"records":{"liet8":{"id":"liet8","name":"test","address":null,"features":null,"selected":true,"createdAt":"Wed Apr 29 2015 07:57:50 GMT+0200 (Paris, Madrid (heure d’été))","level":null,"items":[]},"3kskq":{"id":"3kskq","name":"foo","address":null,"features":null,"selected":false,"createdAt":"Wed Apr 29 2015 07:57:50 GMT+0200 (Paris, Madrid (heure d’été))","level":null,"items":[]}}}"

As you can see, localStorage has 2 mtgTrail, I am able to retrieve on with all, but none with the find function




Aucun commentaire:

Enregistrer un commentaire