samedi 21 mars 2015

Emberjs Fixture adapter queryFixture not working

I have been having an issue implementing the queryFixtures function in Emberjs-Data. I have the following code to define the Store:



App.Store = DS.Store.extend({
revision: 12,
adapter: DS.FixtureAdapter.extend({
queryFixtures: function(fixtures, query, type) {
console.log(query);
console.log(type);
return fixtures.filter(function(item) {
for(prop in query) {
if( item[prop] != query[prop]) {
return false;
}
}
return true;
});
}
})
});


My Model looks like:



FireSurveyApp.User = DS.Model.extend({
userId: DS.attr('number'),
username: DS.attr('string'),
password: DS.attr('string'),
FirstName: DS.attr('string'),
LastName: DS.attr('string')
});


When i try to get the fixture data out i am using the following code:



var returnUser = this.store.find("User",{ username : "Ted"});


The function will return undefined, Is there a different way that i should be calling the queryFixtures function?


Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire