lundi 7 décembre 2015

Adding / Removing relationships with Ember.js / Ember-Data, telling the API what changed?

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.




Aucun commentaire:

Enregistrer un commentaire