在 Ember Data 中,如何定义使用与默认选择不同的模型或外键的 belongsTo/hasMany 关联?
例如,我有一个App.Item
属于模型的App.User
模型,但我想通过owner
属性访问用户:
App.Item = DS.Model.extend({
owner: DS.belongsTo('App.User'),
});
item.get('owner'); // should be an App.User
// And the data from the server looks like:
{
owner: 2, //id
}