3

Ember Data では、デフォルトで選択されるものとは異なるモデルまたは外部キーを使用する属している/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
}
4

1 に答える 1

0

アダプタでカスタム主キーを指定できます。これらは、ストアを作成する前に設定する必要があります。

App.Adapter.map('App.User', {
  primaryKey: 'owner'
});
于 2013-02-03T20:35:58.830 に答える