r/learnrust • u/AdEmotional3301 • 8h ago
LiteORM: A schema-first PostgreSQL ORM for Rust (with a native Desktop Studio)
Hey r/learnrust,
In Rust, using ORMs like Diesel often means writing raw SQL migrations by hand and managing complex query macros.
I built LiteORM to explore a simpler, schema-first approach:
- Define your models once in a declarative
liteorm.schema:
struct User {
id Int32 (autoincrement())
email String
active Boolean u/default(true)
}
- LiteORM does the heavy lifting:
liteorm db pushauto-diffs against PostgreSQL and runs atomic SQL migrations.liteorm generategenerates type-safe Rust structs and query builders.liteorm studioopens a native, cross-platform desktop UI to view/edit data.
- Query with compile-time safety:
rustlet active_users = db
.all(User::select().where_(User::ACTIVE.equals(true)).limit(10))
.await?;
No manual SQL migrations, zero string-concatenation risk (parameterized queries via tokio-postgres), and guards against accidental table wipes on updates/deletes.
- GitHub: https://github.com/unixipher/lite-orm
- Docs & Guide: https://unixipher.github.io/lite-orm/
Would love any feedback on the Rust API design and architecture!
