dimanche 10 décembre 2017

ember-data: error re-adding a previously-deleted record

When trying to add back a record that was deleted from the store with destroyRecord() I get this error:

Attempted to handle event 'loadingData' on <saveditem:4139> while in state root.deleted.saved. Called with {_id: 74001, _label: Fetching saveditem' with id: 4139, _state: undefined, _result: undefined, _subscribers: }.

I've tried the method the docs recommend:

this.get('store').findRecord('saveditem', product.id, { backgroundReload: false }).then(item => {
    item.destroyRecord();
});

and also:

let item = this.get('store').peekRecord('saveditem', product.id);
if (item) {
    item.deleteRecord();
    item.save();
}

But it's the same result. Any help appreciated.




Aucun commentaire:

Enregistrer un commentaire