Repository navigation
|
Can the generated models by Serverpod be used with local databases such as Isar or Hive? In a scenario, there is no internet on my phone, and I need to save data locally and sync later, I currently save it on an Isar database, which also has a class to represent models. Is it possible that Isar and Serverpod use the same model classes? or should there be one model for each database and implement a converter (UserModelIsar and UserModelServerpod)? Or is there already a solution for handling offline-first scenarios that I am not aware of? Thank you! |
Replies: 2 comments 2 replies
|
Converting this to a question since it doesn't seem to refer to a feature request or an issue. Unfortunately, I have not used Isar or Hive. Hopefully, someone in our community can share their experience with this. Serverpod does not yet have integrated support for local database integration. However, Serverpod models can be serialized into a Map. As long as Isar or Hive supports storing a Map it should be possible to call If you create a model using Isar to support querying the local database, you will probably need to implement a converter between them. |
|
It would be very cool if the serverpod cli would generate flutter client code for sqllite (maybe using something like drift). Couple that with something like PowerSync, and you have a very compelling "offline first" architecture. This outlines PowerSync integration, but there if far too much manual coding needed. |
Converting this to a question since it doesn't seem to refer to a feature request or an issue.
Unfortunately, I have not used Isar or Hive. Hopefully, someone in our community can share their experience with this.
Serverpod does not yet have integrated support for local database integration. However, Serverpod models can be serialized into a Map. As long as Isar or Hive supports storing a Map it should be possible to call
toJson()on a model and then store it in any document database.If you create a model using Isar to support querying the local database, you will probably need to implement a converter between them.