How to code universal converter for typed objects #1374
Unanswered
iBobik
asked this question in
Questions and Help
Replies: 1 comment
-
I would use also some more docs on how to properly work with types. E.g. in a custom converter it complains about optional id (because class could be new): |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I migrate existing project where I used pinia-firestore and typed class objects. I want to have all documents in Firestore typed, so I need FirestoreDataConverter to wire types properly.
Currently I use custom converters like this:
Most important part is to pack and unpack class because Firebase wants generic objects. Secondly it converts Timestamps to Dates and vice-versa. Possibly other types will be added when needed.
I want to replace this custom converters by a generic converter what will do it all automatically. I can imagine what to do with Timestamps etc, but I am lost about typings - to use one converter but collections and docs will be properly typed. I does not necessarily need to use classes (I use them only for initialising default values).
Is it possible?
Do you have some working examples?
Beta Was this translation helpful? Give feedback.
All reactions