2017-02-20 41 views
0

我有一个account模型,有以下几点:多重关系

export default Model.extend({ 
    primaryStaff: belongsTo('staff'), 
    secondaryStaff: belongsTo('staff') 
}); 

primaryStaff映射到primaryStaffId关键的account模型和secondaryStaff映射到secondaryStaffId。有没有办法让这些都指向staff模型?

没有任何运气。谢谢!


更新:

我使用JSON API适配器 - 这里有一个样品的有效载荷:

{ 
    "data": { 
    "type": "account", 
    "id": "17", 
    "attributes": { 
     "businessId": 1, 
     "userId": 22, 
     "scopes": [ 
     "customer", 
     "customer-22" 
     ], 
     "keyCode": null, 
     "lockboxCode": null, 
     "notes": null, 
     "active": false, 
     "createdAt": "2017-01-31T20:13:39.465Z", 
     "updatedAt": "2017-02-20T03:49:17.308Z", 
    }, 
    "relationships": { 
     "business": { 
     "data": { 
      "type": "business", 
      "id": "1" 
     } 
     }, 
     "customer": { 
     "data": { 
      "type": "customer", 
      "id": "22" 
     } 
     }, 
     "secondaryStaff": { 
     "data": null 
     }, 
     "primaryStaff": { 
     "data": { 
      "type": "staff", 
      "id": "1" 
     } 
     } 
    } 
    } 
} 

回答

1

您需要修改应用程序(或模型)串行器。

请看看this twiddle

+0

'keyForRelationship'正是我所错过的。非常感谢你! – jdixon04

+0

使用JSON API适配器时,我实际上似乎无法使其工作。查看上面更新的帖子。谢谢! – jdixon04

+0

嗨 - 我以为我有一个通知,你已经做了一些改变,但似乎不再存在。你删除它了吗? – jdixon04