I'm unable to query my models. I don't know what I'm doing wrong.
I have my store defined as
App.Store = DS.Store.extend({
revision: 12,
adapter: DS.FixtureAdapter
});
And my model defined,
var Feature = DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
parent: DS.belongsTo('SimpleTestManager.Feature'),
DS.belongsTo('SimpleTestManager.Project'),
children: DS.hasMany('SimpleTestManager.Feature'),
requirements: DS.attr('string')
});
App.Feature.adapter = DS.FixtureAdapter.create();
App.Feature.FIXTURES = [
{
id: 1,
name: "my first feature",
description: "some description",
parent: null,
project: 1,
children:[2],
requirements: "This is my first feature. It has many requirements."
},
{
id: 2,
name: "a sub feature",
description: "some sub feature.",
parent: 1,
project: 1,
children:[],
requirements: "This is a sub feature."
}
];
When I run the following in the command line
>>App.Features.find({id:'1'})
Error: assertion failed: Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.
I managed to solve the mentioned error by using David Lai's answer, but without extending from DS.Store (the new way after Ember Data 1.0.beta.1):
App.FixtureAdapter = DS.FixtureAdapter.extend({
queryFixtures: function(records, query, type) {
return records.filter(function(record) {
for(var key in query) {
if (!query.hasOwnProperty(key)) { continue; }
var value = query[key];
if (record[key] !== value) { return false; }
}
return true;
});
}
});
App.Store = DS.Store.extend({
adapter: 'Fixture'
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With