lundi 8 février 2016

emberJS 2 : nested relationships resources for actions (update & delete)

I'm asking you about relationships with Ember Data.

I have a User that belongs to an account and a cloud. Datas are well associated with URLs.

The API is done like this :

GET users/:id -> send the user

GET users/:id/account -> send the account status infos

GET users/:id/cloud -> send the cloud status infos

What I need :

I need to be able to update the account and cloud using the user id info. The API expects this :

PATCH users/:id -> update the user

PATCH users/:id/account -> update the account associated to the userId. The userId is enough in the API side, but we can if necessary send the account id like this -> users/:id/account/:idaccount

The same URLs with the DELETE http method to DELETE accounts.

When I trigger a "model.get('account').get('content').save() it sends

accounts/:idaccount

But our API doesn't work like this...

Do you have an idea about how I could manage it ?

Thanks a lot !

Aucun commentaire:

Enregistrer un commentaire