angular-async-local-storage: Update instead of Add? – re: Error: IndexedDB setter issue : Key already exists in the object store
This is more of a question as to the correct approach to updates to data in the local store, not an issue or a bug, so my apologies if this isn’t the correct venue.
I’m running into this error (correctly, I might add):
error occured setting data in the local store Error: IndexedDB setter issue : Key already exists in the object store
This occurs where I’ve set a key in the store, and then later am trying to reset a value for the same key, and it throws the above error. I can’t anticipate when the user will navigate through a specific workflow that will cause a value to be fetched from over the network and re-added to the local store, so I’m trying to determine the best way to handle this.
My understanding is we can only add, not update(put) an object into the store, which brings me to the question of how to handle updates. Ideally I would like to update by default any existing value for a key already in the store, but failing that, is the accepted approach to always test for the presence of a key, and if it exists, to delete it first, then add the new value with that key?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (10 by maintainers)
Released in stable (v6.1.1 and 5.3.1).
Thanks all for your feedback, it was a previously reported issue, but as I had no feedback in the previous reports, I wasn’t able to spot the problem.
@alignsoft Thanks for testing.
@joeskeen Let me know if there is still a problem when you’ll test.
Just tested it, it’s working great now! Thanks @cyrilletuzi for the quick fix!