Closed
Description
Given
data class Article(
val title: String = "",
val subTitle: String = "",
val image: String = "",
val date: Double = 0.0,
val content: String = ""
)
Firebase.firestore.collection("articles")
.get()
.documents
.map { doc ->
Article(
doc.get("title"),
doc.get("subTitle"),
doc.get("image"),
doc.get("date"),
doc.get("content")
)
}
When
date
is type timestamp in Firestore.
Then
How do we decode this type in commonMain for example? I have tried setting Article.date to String and Double and both crash.
kotlinx.serialization.SerializationException: Expected Timestamp(seconds=1606944088, nanoseconds=0) to be double
Does the SDK provide any method to help with decoding this automatically?