Support for Cloud Datastore in Dart without relying on `dart:mirrors`
bwnyasse opened this issue · 2 comments
Description:
I'm currently using the gcloud package in my Dart application to work with Cloud Datastore. However, I encountered an issue when trying to use the package with the Cloud Datastore due to the reliance on the dart:mirrors package. The dart compile command fails with the following error:
error: import of dart:mirrors is not supported in the current Dart runtime
Error: AOT compilation failed
Generating AOT snapshot failed!
I believe it would be beneficial to provide an alternative way to define Datastore models without relying on the dart:mirrors package. This would enable the use of Cloud Datastore in Dart applications without encountering the reflection-related limitations imposed by the Dart runtime when calling dart compile command.
In the documentation, the usage of the @db.Kind() and @db.Property() annotations from the gcloud package is demonstrated. However, since Dart's AOT compilation does not support dart:mirrors, it would be helpful to have an alternative approach for defining Datastore models that doesn't rely on reflection.
My use case:
I am trying to use the package to build a faas with functions-framework-dart . When building the tiny docker image, the dart compile command fails if I use Datastore library.
I'm one of those who would like to see this issue resolved. I also want to realize FaaS by Dart, but I'm about to give up due to the error of this dart compile :-(
This is interesting to see here. If I'm not mistaken, defining these models is similar to the firestore problem that the cloud_firestore_odm package tries to solve for the cloud_firestore package, that takes a different approach. Since dart:mirrors isn't available on mobile, the odm package uses a build runner step.
If there is an irony, it's that cloud_firestore_odm comes with plenty of gotchas of its own, leaving the dev wishing they could use some type of reflection... like server devs.