-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Description
Add user defaults migration helper, which takes a list of of MigrationInfo
. MigrationInfo
is a struct that contains a KeyType
to be migrated to, String
which is the old key, and a processing block, that takes the old value and processes it to to return a new suitable value for KeyType
.
This is the actual use case that I have. I have simplified it so it makes more sense:
old value: "CityId" -> "kw-city-asimah"
new key: "general-settings:city" -> ""
so, we can do this:
let migrationInfo = MigrationInfo(
keyType = Key<GeneralSettings, City>(id: "city", defaultValue: City.asimah),
oldKey = "CityId",
processor = { oldValue in
// process from a string to a City type
return mydb.getCity(oldValue)
})