| Crates.io | premix-orm |
| lib.rs | premix-orm |
| version | 1.0.6-alpha |
| created_at | 2026-01-18 05:24:47.60412+00 |
| updated_at | 2026-01-20 20:33:12.498591+00 |
| description | Alpha research ORM for Rust. Facade crate for premix-core and premix-macros (not production-ready). |
| homepage | |
| repository | https://github.com/premix-labs/premix-orm |
| max_upload_size | |
| id | 2051831 |
| size | 59,042 |
Premix ORM is a zero-overhead, type-safe ORM for Rust, designed for performance and developer experience.
This crate (premix-orm) is the official facade that re-exports premix-core and premix-macros, providing a unified entry point for your application.
This crate is part of a research prototype. APIs may change and production use is not recommended yet.
use premix_orm::prelude::*; gets you everything.Cargo.toml.Add this to your Cargo.toml:
[dependencies]
premix-orm = "1.0.6-alpha"
sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
Enable database features on both premix-orm and sqlx:
premix-orm = { version = "1.0.6-alpha", features = ["postgres"] }
sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite", "postgres"] }
use premix_orm::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Model, Debug, Serialize, Deserialize)]
pub struct User {
pub id: i32,
pub name: String,
// Soft delete is auto-detected by field name.
pub deleted_at: Option<String>,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pool = Premix::smart_sqlite_pool("sqlite::memory:").await?;
// Sync schema.
Premix::sync::<premix_orm::sqlx::Sqlite, User>(&pool).await?;
// CRUD.
let mut user = User { id: 0, name: "Alice".to_string(), deleted_at: None };
user.save(&pool).await?;
println!("Saved user with ID: {}", user.id);
Ok(())
}
deleted_at conventionsqlx feature flagssqlx with matching database featuresFor a longer-form guide, see orm-book/ in this repository.
Inspect the SQL generated by the query builder:
let query = User::find_in_pool(&pool).filter_gt("age", 18).limit(10);
println!("{}", query.to_sql());
See the book for more on generated APIs and SQL inspection: orm-book/src/queries.md.
Run raw SQL while mapping results to your model:
let users = User::raw_sql("SELECT * FROM users WHERE active = 1")
.fetch_all(&pool)
.await?;
This project is licensed under the MIT license.