0

I have two models in a many-to-many relationship. On the Ember side I'm setting both up in my model. When I go to add a new relationship between the two of them I'm using model.get('relationshipName').pushObject(otherObject), and then model.save(); The call to the API goes over and simply lists all known relationships as an array of IDs. The main question here would be, is this correct? It seems a bit odd that the API has to then fetch a list of known relationships and compare it to the list of relationships that Ember sends over. Is there a better way to go about this so that I can better inform the API of what relationship has been modified, whether it's adding a new one or removing an existing relationship?

This is using Ember 2.2 and Ember-data 2.2, along with the default RESTAdapter.

Ethan Brown
  • 26,892
  • 4
  • 80
  • 92
  • I think that this is the price we have to pay for ember-data and crud api. If you need this for stuff that will be frequently updated and collisions can occur you can always just use plain ajax with LINK/UNLINK methods and update store manually. – Keo Dec 08 '15 at 01:52
  • Thanks. It does seem that way, and it makes sense because Ember is just sending over everything it knows about that model. Thinking about it more, because I'm only updating the relationship in this instance there's no need to save the model. I could just update it in Ember's memory and then send some information to a custom endpoint telling the API to add / remove the relationship. – Eric Buchmann Dec 09 '15 at 23:07

0 Answers0