-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleted records are not accessible #1737
Comments
I'm not sure. Let's dig into this a bit, I may be experiencing a related issue. Here's an action in a route for deleting some record: // In some route...
actions: {
deletePost: function (post) {
post.deleteRecord();
post.save().then(
function () {
console.log("I succeeded! I'm removed from the store, and the API is happy.");
},
function () {
console.err("Oh snap! The API is angry. I'm not in the store though!");
console.err("isDeleted:", post.get('isDeleted'), "; isDirty:", post.get('isDirty'));
post.rollback();
console.err("Oh snap! I'm still not in the store.");
console.err("isDeleted:", post.get('isDeleted'), "; isDirty:", post.get('isDirty'));
}
}
} When you What I'm finding is that you can't rollback a delete. Is that what your issue is too? |
@jherdman can you show where u are creating and assigning to the |
Oops! That was a mistake in my code above. I've edited it to read "post" instead of model. My bad. |
The main issue for me is that I do not want to persist the record right away but only when the user explicitly requests it but at that point the record isn't accessible in any way I found... I can't even check if a record is waiting to be persisted (for deletion) as the record is gone. The only way I found was to keep my own indication but that is an ugly workaround... |
Hmm... We definitely have separate issues then. FYI you can accomplish your usage like this: actions: {
deleteRecord: function (myRecord) {
myRecord.deleteRecord();
if (confirm("Are you sure about this?")) {
myRecord.save(); // persisting happens here
}
}
} |
The use case may be different but the root cause seems the same to me. I'm aware of this way of implementation but in my case the confirmation needs to be in a latter interaction with the user and not right away. |
@simonweil it sounds like for your use-case you should be using a custom flag on the object to mark it for deletion rather than actually deleting in the first instance and then on confirm actually perform the deletion? |
This solution would work but it's got a big downside, every place I present the And anyway, EmberData holds this info, it's just inaccessible to me, so it's a workaroumd and not a very nice one... What I think of doing is keeping some sort of reference to the record for usage later - a solution I don't really like either. |
@simonweil yep, you'll need to filter but that kinda comes with your application by the sounds of it. I'm gonna close this ticket, @jherdman yours is a separate issue, can you see if there is an issue open or create one otherwise. Cheers. |
It's up to you, but IMHO this is a general issue that needs addressing. What is the purpose of If there is a record "marked" for deletion but needs another step to actually delete it, then there must be a way to reach the record otherwise as I wrote it's an option that is not usable. Please reconsider. |
IMO it's a rare case where you're not deleting and saving within the same action. I'm reopening, I'd love to hear some thoughts on the API |
I have many use cases where delete is happening before save. For example I open up a dialog for editing or creating one object that has bunch of sub-objects. User can change name of the main object, add and delete sub-objects, change sub-object names in one dialog. Then user can either click "Save" or "Cancel". This is very common pattern in many admin UI-s. |
The docs also state that a deleted record can be rolled back:
|
I'm excited to see there is progress on this issue as it seems anything that you can save() you should be able rollback, as you guys have mentioned. |
Any progress on this? |
+1 for Save/Cancel deleteRecord use case It's not a question of whether I can track deleted records, it's a question of whether I should need to track deleted records. New and modified records are tracked for me and I call save when necessary. Why should deleted records be so different that I need to track pending deletions myself? |
+1 |
+1 |
+1 |
1 similar comment
+1 |
Any use case that does not persist records immediately can benefit from this feature. |
+1 |
Closing this since #3539 has been merged 🎉 This is going to be available (as a breaking change) in Ember Data 2.0. Details will be explained in the upcoming ED 2.0 blog post. |
Great news, thank you :) |
When running
deleteRecord()
the record is removed from thecontent
of the controller and therefore can't access the record to run thesave()
command to persist the deletion.Another issue I came across is that after deleting the record I have no indication that I have records that need persisting if I do now wish to persist them right after I run the
deleteRecord()
command.Is this really a problem or am I missing something?
The text was updated successfully, but these errors were encountered: