S
SolidJS11mo 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
gsoutzOP11mo 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
gsoutzOP11mo ago
can you just write me an infrastructure for handling this step.
bigmistqke
bigmistqke10mo ago
you can version the data and write migrations
bigmistqke
bigmistqke10mo 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
gsoutzOP10mo ago
Oh good reference thanks for this.
bigmistqke
bigmistqke10mo ago
Ur welcome!
Want results from more Discord servers?
Add your server