2

I'm developing a push application and need to remove items from a DS.Store without invoking any actions. I'm able to insert objects using load(), but need to be able to "unload" an object after it has been deleted on another client.

Thanks

barcrab
  • 201
  • 2
  • 12

2 Answers2

14
record.unloadRecord();

This clears belongsTo and hasMany relationships on the record and then transitions the record to the deleted.saved state, all without sending anything to the server.

Jonathan Tran
  • 14,594
  • 9
  • 57
  • 64
  • however, [#unloadRecord](http://emberjs.com/api/data/classes/DS.Model.html#method_unloadRecord) is private – Sam Selikoff Nov 26 '14 at 16:32
  • @SamSelikoff: You are right, so use the unload record from the store object: http://emberjs.com/api/data/classes/DS.Store.html#method_unloadRecord – Jacob van Lingen Jun 24 '15 at 12:49
2

Rather than remove a record from the store I just need to change the record state.

record.get('stateManager').goToState('deleted.saved');

For ember-data V ~1.0 use:

record.transitionTo('deleted.saved');
Mutual Exception
  • 1,042
  • 9
  • 22
barcrab
  • 201
  • 2
  • 12