You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi there,
This is quite handy! thanks for sharing.
A question, the decoder throws when Firestore record doesn't exactly match with Class property definition, anyone has recommendation how to handle adding or removing fields between client versions?
for example, myApp version 1 stores object "People" with 2 fields "NameFirst" and "NameLast", using encode and decode are working great.
when i'm doing myApp version 2, when I add a new propoery "PhoneNumber" to People class, the decode throws and return nil, as the new field PhoneNumber doesn't exist in other existing records.
what are the consideration when we decided to throw, rathan than just return nil to the fields that doesn't exist?
thansk!
guard let entry = self.container[key.stringValue] else {
throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\")."))
}
The text was updated successfully, but these errors were encountered:
Well, in general having extra data in the model will not cause the error, it's only the missing one. So if you have different version of the app, you need to make sure that they only add new data not delete anything. This way you will never have any errors.
hi there,
This is quite handy! thanks for sharing.
A question, the decoder throws when Firestore record doesn't exactly match with Class property definition, anyone has recommendation how to handle adding or removing fields between client versions?
for example, myApp version 1 stores object "People" with 2 fields "NameFirst" and "NameLast", using encode and decode are working great.
when i'm doing myApp version 2, when I add a new propoery "PhoneNumber" to People class, the decode throws and return nil, as the new field PhoneNumber doesn't exist in other existing records.
what are the consideration when we decided to throw, rathan than just return nil to the fields that doesn't exist?
thansk!
The text was updated successfully, but these errors were encountered: