You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sqflite adapter for Serverpod protocol classes #1719
I need to persist some data locally on my Flutter client, to reduce redundant requests for the same data to the server, and I want to be able to use the same interface for storing data in SQLite on the client (via sqflite) that I use for writing data to Postgres on the server.
It would be super awesome if Serverpod supported this out of the box (I'm sure I'll have to write my own version of this before you get to it, but it's an important feature to support generically).
What I plan to do is cache records on the client, and only download new/changed records as necessary from the server, then run all queries against the client copy of the data.
I want to be able to receive a list of protocol objects from the server, and write them directly to SQLite, with the data split out into columns, just as it is on the server.
It would be great if serverpod generate could generate a client (SQLite) variant of the Postgres SQL table creation code for any protocol objects (and fields thereof) that are sent over the wire (as opposed to being server-database-only), with appropriate indexes.
Reacted by Lukas Mirbt, Tsung-Han Yu and Kieran Lee
We could build some smart persistence and offline support on top of this too. Such as the ability to save things offline and then sync when the device gets online again.
Yes, exactly. I was going to write a "poor man's sync" for append-only tables (eg chat history), where the difference in row count between the client and a user-specific view on the server is all that is needed to know how many additional rows to fetch, but probably a slightly more powerful sync capability would be possible without the complexity of full replication sync support.
Since discussions don't seem to create backlinks I'll add it manually: #2084 - the CRDT pattern could solve this as well as #2080 which is pretty much the same as this ticket but with a different database backend, as there is a CRDT implementation for both this could be a good way forward.
Activity
Isakdl commentedon Jan 8, 2024
This is a pretty cool idea!
We could build some smart persistence and offline support on top of this too. Such as the ability to save things offline and then sync when the device gets online again.
lukehutch commentedon Jan 8, 2024
Yes, exactly. I was going to write a "poor man's sync" for append-only tables (eg chat history), where the difference in row count between the client and a user-specific view on the server is all that is needed to know how many additional rows to fetch, but probably a slightly more powerful sync capability would be possible without the complexity of full replication sync support.
dkbast commentedon Apr 2, 2024
Since discussions don't seem to create backlinks I'll add it manually: #2084 - the CRDT pattern could solve this as well as #2080 which is pretty much the same as this ticket but with a different database backend, as there is a CRDT implementation for both this could be a good way forward.
marcelomendoncasoares commentedon Aug 12, 2026
We now have SQLite generated on the client since 3.5.0-beta, which will be out on the official 4.0.0.