Skip to content

Instantly share code, notes, and snippets.

@doublejosh
Last active August 29, 2015 14:14
Show Gist options
  • Save doublejosh/0e55782402f5e867dc9c to your computer and use it in GitHub Desktop.
Save doublejosh/0e55782402f5e867dc9c to your computer and use it in GitHub Desktop.
/**
* Data transforms due to version updates.
*/
function schema() {
// Update keys.
var keys = {
'MY-NEW-KEY': {'oldKey': 'MY-OLD-KEY', 'version': '0.2.0'}
};
for (var newKey in keys) {
if (!$.jStorage.get(newKey) && ($.jStorage.get(keys[newKey].oldKey !== null))) {
$.jStorage.set(newKey, $.jStorage.set(keys[newKey].oldKey));
$.jStorage.deleteKey(keys[newKey].oldKey);
if (typeof console != "undefined") console.log('Updated storage key: ' + newKey);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment