CodableFirebase
CodableFirebase copied to clipboard
Setup Decoder to decode (FIR)Timestamp to (NS)Date
Now that Firestore warns us to/ forces the usage of Timestamps over Dates I'm looking for a way to workaround this.
Background: I'm using Models on iOS and watchOS as well. Firebase is not ready for watchOS hence I cannot use Timestamp in the models. Besides this I'd prefer to avoid the Firestore dependency in my models. The precision of Date is more than enough for me.
My models are also contained in a framework that is not aware of Firebase, hence I cannot implement/ override the decoder that parses the Timestamps into Dates.
Question: Is there a way to setup the FirestoreDecoder to automatically parse Timestamps to Dates when a Date is expected in a model?
Would really love a solution for this as well! I'm personally not very fond of timestamps. It's essentally rendering CodableFirebase obsolete for a lot of people until we crack it. It's breaking my models apart
Did anyone fix this problem ?
Seconding this sentiment. Any progress here?
Still no fix?
It'd be great to see such mapping in this library. Exposing Firebase Timestamp type to models is something all developers should stay away of.
Can we get this fixed? It is now breaking everything
+1.
Updated to the latest Firestore for their new groupCollection query method, but now it gives me this error when I run the app.
Swift.DecodingError.typeMismatch(Foundation.Date, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "createdAt", intValue: nil)], debugDescription: "Expected to decode Date but found FIRTimestamp instead.", underlyingError: nil))
+1
1+
Hi guys.
I fixed that issue.
Here you can find solution: https://github.com/mshershnev/CodableFirebase Code example is here: https://github.com/alickbass/CodableFirebase/pull/86#issuecomment-584675760
I did pull request and hope that it will be merged soon: https://github.com/alickbass/CodableFirebase/pull/86