ember-data不支持嵌入对象 [英] ember-data does not support embedded objects
问题描述
谢谢
对于Ember Data 1.0 beta +有效,请参阅重复的答案
Ember数据仍然支持嵌入式。你只需要正确的配置。这里你可以如何做:
DS.RESTAdapter.map('App.Foo',{
bar: {
embedded:'always'
}
})
App.Foo = DS.Model.extend({
bar:DS.belongsTo App.Bar,{embedded:'always'}),
});
嵌入式可用值为:始终和加载。
加载:加载时嵌入子记录,但应将
保存为独立记录。为了这个工作,孩子记录
必须有一个ID。
始终:加载时子嵌入,并保存
嵌入同一条记录。这当然会影响
的肮脏记录(如果子记录更改,适配器会将
父记录标记为脏)。
类似的设置适用于HasMany关系,有关详细信息,请参阅此回复。
i'm working with ember data rev-11 and django tastypie. Looks like now ember-data does not support embeded resources but support sideloads (django tastypie does not support it). What is the best solution?
Thanks
This is not valid for Ember Data 1.0 beta+, see duplicate answer
Ember-data still supports embedded. You just need the right configuration. Here how you can do it:
DS.RESTAdapter.map('App.Foo',{
bar:{
embedded:'always'
}
})
App.Foo = DS.Model.extend({
bar: DS.belongsTo(App.Bar,{embedded:'always'}),
});
Available values for embedded are: always and load.
load: The child records are embedded when loading, but should be saved as standalone records. In order for this to work, the child records must have an ID.
always: The child records are embedded when loading, and are saved embedded in the same record. This, of course, affects the dirtiness of the records (if the child record changes, the adapter will mark the parent record as dirty).
Similar settings apply for HasMany relationship, see this reply for more details
这篇关于ember-data不支持嵌入对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!