<@U6647LJ30> Working with Firebase’s Firestore isn’t very convenient in Kotlin. How feasible is it t...
s
@sandwwraith Working with Firebase’s Firestore isn’t very convenient in Kotlin. How feasible is it to leverage kotlinx.serialization to “serialize” between kotlin classes and object formats that Firestore requires in Kotlin multiplatform? i.e. • In JVM I’d need to take a Kotlin data class and convert it into
Map<String, Any>
and
Date
representations into Firestore’s
Timestamp
. • In JS I’d need to output js objects (Not kotlin Map’s or anything) Assuming this is possible: 1. Would I be able to stay away from Compiler plugins and stick only to the runtime? 2. Would configuring an object to change to Firestore types present any problems to that same object being serialized to json?
s
1. Yes, that's what the custom formats mechanism for. 2. I don't get what 'configuring an object to change to Firestore types' mean. Changing the types in the object declaration? Then the answer depends on how that types are serialized to json.
s
@sandwwraith 1. Can you give me more information and point me in the right direction for the custom formats mechanism? 2. Nevermind, I’m pretty confident this won’t be an issue.
s
Yes, exactly
s
Man - you have great documentation for this! This is exactly what I was looking for. I’m pretty excited for this!
😉 1
@sandwwraith Do I have the ability to have information of custom annotations in the encoder?
s
Yes, they are stored in the corresponding
SerialDescriptor.annotations
(for class)
SD.getElementAnnotations
(for properties)
Annotation should be marked as
@SerialInfo
itself