Partial update in Ember-Data?

Imagine a bug tracker.

Each ticket contains a lot of data. Now the status of several tickets from the long list of tickets is updated.

App.Ticket = DS.Model.extend({ id: DS.attr('number'), status: DS.attr('string'), ... }); 

Currently, when save called in ember-data, this will send complete models to the server.

What can be done to send only a partial update, for example [{"id": 1, "status": "closed"}, {...}] ?

PS: I understand that this is impossible now, so I wonder if there is a workaround / modification that would allow this to be done? (one-stop solution is not required).

+6
source share
2 answers

My current workaround is to specify the readOnly parameter, which excludes attributes that I don't want to send to POST.

Details can be found here: https://github.com/emberjs/data/pull/303#issuecomment-13993905

+3
source

I also studied this, and if you want this to apply to all saves, today you will fix it using a serializer like serializers/ticket.js :

 import DS from 'ember-data'; export default DS.RESTSerializer.extend({ attrs: { status: {serialize: false} } }); 

This will share status .

+1
source

All Articles