Skip to content

sqflite adapter for Serverpod protocol classes #1719

Closed

Description

@lukehutch

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.

Activity

  1. Isakdl commented on Jan 8, 2024

    @Isakdl
    Collaborator

    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.

  2. added
    enhancement
    on Jan 8, 2024
  3. lukehutch commented on Jan 8, 2024

    @lukehutch
    ContributorAuthor

    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.

  4. dkbast commented on Apr 2, 2024

    @dkbast
    Contributor

    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.

  5. added
    area: client
    on Dec 2, 2024
  6. marcelomendoncasoares commented on Aug 12, 2026

    @marcelomendoncasoares
    Collaborator

    We now have SQLite generated on the client since 3.5.0-beta, which will be out on the official 4.0.0.

  7. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clientenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions