Reputation: 404
Is there a commit method for the fixture adapter? What does it do?
As my understanding goes store.commit()
puts an API call when used with REST adapter.
Can I use isLoaded
property with fixture adapter?
Basically I have 2 records in my controller called x
and y
and a property content that has many records of y
type.
Coffee code below:
someMethod: (->
content.removeObject(y)
).('x.isLoaded')
anotherMethod: ->
//modify x
Application.store.commit()
When I call anotherMethod
it updates x
and runs a commit on store, hence someMethod
gets called.
My actual application runs fine but in case of tests someMethod
removes the record y
from content as well as store.
Is it that isLoaded
and commit
are not for fixture data store?
Upvotes: 2
Views: 6703
Reputation: 141
Yes, there is a commit method and it is accessible through DS.Store or DS.Transaction.
Here's a fiddle that has some good code that quickly demonstrates CRUD with fixtures.
window.App = Ember.Application.create();
App.store = DS.Store.create({
revision: 4,
adapter: 'DS.fixtureAdapter'
});
App.Person = DS.Model.extend({
id: DS.attr('number'),
name: DS.attr('string')
})
App.Person.FIXTURES = [
{id: 1, name: 'Fixture object 1'},
{id: 2, name: 'Fixture object 2'}
];
App.people = App.store.findAll(App.Person);
App.store.createRecord(App.Person, {id: 1, name: 'Created person'});
App.personView = Em.View.extend({
isVisibleBinding: 'notDeleted',
notDeleted: function() {
return !this.getPath('person.isDeleted');
}.property('person.isDeleted').cacheable(),
remove: function () {
this.get('person').deleteRecord();
}
});
Upvotes: 8