Lithair learns SQL — and lists everything it refuses to promise
说明与用途
Lithair 引入实验性的 Turso SQL 存储,保持内存优先的保证。每个模型只能使用一种数据源,未支持的功能会在编译时报错或启动失败。最近的版本修复了迁移、分页和关键的重放错误。
问题
Adding SQL storage to a memory‑first framework without breaking its guarantees and without introducing hidden promises.
结果
Lithair successfully integrates SQL storage on a per‑model basis while preserving its memory‑first guarantees. Unsupported features are caught at compile time, and the framework refuses to start in configurations that could lead to data loss. Recent releases addressed migrations, pagination, parity, and a critical replay bug.
工作流
- 1. Add
lithair-tursocrate to Cargo.toml. - 2. Annotate a model with
#[storage(turso)]and declare primary key and validations. - 3. Register the model with
LithairServer::new().with_model::<Archive>("./data/archives", "/api/archives"). - 4. On startup, Lithair opens the Turso database and generates CRUD routes.
- 5. The framework rejects any SQL model that requests unsupported features (e.g., foreign keys, SSE, Raft).
- 6. If the server contains both native and SQL models, it refuses to start to avoid incomplete backups.
- 7. Use the provided migration syntax (
version = 2, migrations(note_v2)) to evolve schemas. - 8. Pagination now returns
has_moreandnext_offsetfor SQL lists. - 9. Ensure DELETE responses match native semantics or adjust client parsing.
证据
Lithair does not depend on the Turso driver. A native application doesn’t compile it, doesn’t download it, doesn’t know it exists.
The framework doesn’t pretend to do that for you.
The same day, an application built on Lithair reported this: create a record, delete it, restart the server — and the GET on the deleted ID answers 200.
- 记录日期: 2026-09-22T04:00:40.248Z