Single record persistence with ember
In Ember.js with ember-data (using the 1.0pre versions) all changes to the data are saved into a defaultTransaction on the store. When the store is committed with store.commit()
ALL changes to the data are saved back to the API (using the RESTAdapter).
I would like more control over objects being persisted. So for now, I have been getting instances of store and adapter, then calling something like adapter.createRecord(store, type, record)
or updateRecord
where type
is the App.Person
model and record is an instance of that model.
This is using internal bits of the DS.RESTAdapter
that I don't think are meant to be used directly. While it works I'm hoping there is a better way to gain more control over persistence then store.commit()
. The business logic and UX of my application require finer control.
transaction = router.get('store').transaction();
person = transaction.createRecord(App.Person);
person.set('name', 'Thanatos');
transaction.commit();
watch yehuda presentation regarding this. http://www.cloudee.com/preview/collection/4fdfec8517ee3d671800001d
链接地址: http://www.djcxy.com/p/64068.html上一篇: 管理交易和关系
下一篇: 带有余烬的单个记录持久性