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: }.
As a side comment, it is not clear for me how is your usercase (the why do you want to add back a deletes record).
In Ember-data, if any record change in local, this must be saved in order of perform a request to the server where it is stored (destroyRecord() perform a request too).
But if by example, this call fails in the server, the way to “restore” the record in local, is with rollbackAttributes().
Thanks for answering! I can think of a couple of use cases (more if I really thought about it). If you had a shopping cart and a customer deleted a line item. Then changed their mind and re-added it.
My use case is I am trying to keep a “saved item” list for logged in users. In my testing I discovered that a deleted item can’t be added back. Similar to the cart use case, a customer should be allowed to change their mind.
This restriction (if it is one) of not being able to add back a record with the same id as a previously deleted one, is not a pattern I’ve ever seen with any database I’ve worked with. Which makes me wonder if I am just doing it wrong. Or possibly, it could be a bug.
The error does not happen when the record is deleted, it happens when it’s being added back again AFTER deletion.