-
Notifications
You must be signed in to change notification settings - Fork 63
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
Allow delete() on index #68
Comments
Makes sense to me. |
What would happen if |
I agree that this makes delete operations on indexes somewhat different than delete operations on objectStores. However I don't think it's awkward or surprising enough behavior that it'll result in website bugs. So I think the fact that there is author demand for this feature, as well as a relatively low cost of implementation, makes it worth adding this feature. Originally we did indeed put this limitation there since the index is a "window" into the objectStore. However I think that we were overly conservative, and updating and deleting objectStores "through" indexes makes authors lives easier enough that we should allow it. |
While I think delete on key cursors is a no brainer, I'm not quite sure on this one. While difficultly of implementation may be a vote against a particular feature, ease of implementation should not necessarily be a vote for the feature. Author demand is definitely a vote in favor of the feature. Bizarre behavior of the feature might be a vote against it. For example, I am kind of caught up on the multiEntry thing. I think it's potentially bizarre and unexpected that deleting a single "record" might cause the index's count to drop by more than 1. I don't yet have a conclusion on this one. |
I do agree that ease of implementation is not an argument for. It was more meant as a "implementation burden is not an argument against in this case". I'm not sure if this is an argument for or against, but even without multiEntry the count can drop by more than one if you do |
Note that this happens today when calling |
TPAC 2019 Web Apps Indexed DB triage notes: Due to the complication and that it's not a frequent request, we're closing this out. We're happy to hear more use cases for this feature to cause us to revisit. |
I'd like to +1 this feature. My use case is that I had a little helper function like this: function deleteAll (store, storeOrIndex, keyRange) {
storeOrIndex.getAllKeys(keyRange).onsuccess = e => {
for (const result of e.target.result) {
store.delete(result)
}
}
} Then I realized that Except then I noticed the My precise use case is that I'm deleting data from an object store based on a foreign key. (E.g. delete a post, and delete all replies to that post.) This, along with the "delete everything with |
Here's a use case for being able to call delete() on an index:
http://stackoverflow.com/questions/35511033/how-to-apply-expiry-times-to-keys-in-html5-indexeddb/35518068#35518068
Scenario: delete all records > 24 hours old
If you create an index on a timestamp field you can open an index cursor over the range and delete every value. But if you could call
delete(range)
on the index directly you could avoid iterating through script.The text was updated successfully, but these errors were encountered: