S
SolidJS7mo ago
gsoutz

How to update data saved on local storage

I save data on local storage, but I might change the structure of the data or how I use it, which might break the users that is keeping the old data structure in their local storage. What is the best way to handle this update of local data.
8 Replies
Raqueebuddin Aziz
Show a dialog asking the user to backup their current data, just export the localstorage value as a file for backup and then just update the value, if anything goes wrong give them the option to restore
gsoutz
gsoutz7mo ago
ok I am not doing any of that, how do I make this automatic smoothless and non intrusive
Raqueebuddin Aziz
You can skip the backup and restore step
gsoutz
gsoutz7mo ago
can you just write me an infrastructure for handling this step.
bigmistqke
bigmistqke7mo ago
you can version the data and write migrations
bigmistqke
bigmistqke7mo ago
there are probably libs for it but it's not so difficult to write your own: https://levelup.gitconnected.com/an-approach-to-javascript-object-schema-migration-ae1bd9f0ce78
Medium
An Approach to JavaScript Object Schema Migration
Recently, I found myself in a position where an application was heavily reliant on a state object. This is fairly typical for single page…
gsoutz
gsoutz7mo ago
Oh good reference thanks for this.
bigmistqke
bigmistqke7mo ago
Ur welcome!
Want results from more Discord servers?
Add your server