| Crates.io | luhorm |
| lib.rs | luhorm |
| version | 0.0.4 |
| created_at | 2026-01-22 00:30:34.917434+00 |
| updated_at | 2026-01-22 02:58:19.159185+00 |
| description | a compile time orm for rust! |
| homepage | |
| repository | https://github.com/calizoots/luhorm |
| max_upload_size | |
| id | 2060504 |
| size | 458,855 |
A compile-time ORM that generates type-safe database code through build-time introspection. Supporting Sqlite and Postgresql out the box but extensible to another database
must have rand & chrono in Cargo.toml
must have sqlx
build.rs:use luhorm::Codegen;
use sqlx::sqlite::SqlitePoolOptions;
#[tokio::main]
async fn main() {
let pool = SqlitePoolOptions::new()
.connect("sqlite:my_db.db")
.await
.unwrap();
Codegen::new("orm", pool, "migrations", None)
.await
.unwrap()
.run_codegen()
.unwrap();
}
src/main.rs:mod orm {
include!(concat!(env!("OUT_DIR"), "/orm.rs"));
}
use crate::orm::{users::{Users, UsersBuilder}, entry::AggregateEntryUsers};
let users = Users::query()
.name("alice")
.age_gt(18)
.fetch_all(&pool)
.await?;
let x = Users::query()
// could do this aswell
// .join(Entry::NAME, Users::ID.of(), Entry::USERID.of())
.join_entry()
.fetch_with_entry(&pool)
.await?
.one_to_many()?;
// new feature might change
let new_user = UsersBuilder::new()
.populate_fake_data()
.build();
new_user.insert(&pool).await?;
made with love - s.c 2026