-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Code health] Introduce protos as structure for checking data in Firestore at compile-time #2049
Comments
Perhaps something like JSON Schema could also work? Code gen: |
There's currently no easy way to do this. We could use something like quicktype to generate model code from JSON Schema, but that would require data to be converted to JSON and then parse (wasteful), and it's not as customizable so classes like GeoPoint won't be accessible. Firestore doesn't support this by design (filed this FR), so we'd need to roll our own. Dart isn't supported on Cloud Functions (see FR), so even if we can share model and logic between Angular and Android, we'd still need another impl there. |
A good place to start might be https://sianloong90.medium.com/step-by-step-build-a-kotlin-multiplatform-library-sdk-part-1-e973bdbfa55d |
A few more notes:
|
@jcqli Moving out of this iteration for now since we punted on this. |
See also google/ground-platform#1277
@os-micmec FYI tracking bug also here
Proposed micro-design (read):
DocumentSnapshot.getData()
to fetch data as aMap<String!, Any!>
Map
when needed. We should try to minimize special logic in this layer.Map
in GsonJsonElement
and related classes.json-kotlin-schema-codegen
We would do the reverse for writing:
Map
to update methods in Firestore libs.We can preserve our current representation of nested arrays, using indexed maps instead.
Alternatives considered:
PropertyMap
interface. It's also not clear how we'd implement polymorphism or custom (de)serializers.kotlinx.serialization Properties requiresAlso not correct - you can set custom annotations@Serialization
annotations on data classes (issue). Our data classes are generated, so we can't do that.Gson and kotlinx.serialization Json require conversion to/from JSON strings, which can be slow.<-- not true - we can also recursively wrap our object graph toJsonObject
andJsonElement
as per this exampleDocumentSnapshot.toObject
doesn't handle polymorphism, and doesn't offer much flexibility in customizing mappings.@sufyanAbbasi FYI
Comments which follow are from early research and are out of date.
The text was updated successfully, but these errors were encountered: