premix-orm 1.0.3

The comprehensive ORM library for Rust. This is a facade crate for premix-core and premix-macros.
Documentation
# Premix ORM


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.

## Why use this facade?


Previously, users had to manage both `premix-core` and `premix-macros`. With `premix-orm`, you get:

1. Unified imports: `use premix_orm::prelude::*;` gets you everything.
2. No version mismatch: core and macros versions stay compatible.
3. Clean dependencies: only one crate to add to your `Cargo.toml`.

## Installation

Add this to your `Cargo.toml`:

```toml
[dependencies]
premix-orm = "1.0.3"
sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
```

## Database Features

Enable database features on both `premix-orm` and `sqlx`:

```toml
premix-orm = { version = "1.0.3", features = ["postgres"] }
sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite", "postgres"] }
```

## Quick Start


```rust
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<chrono::DateTime<chrono::Utc>>,
}

#[tokio::main]

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let pool = SqlitePool::connect("sqlite::memory:").await?;

    // Sync schema.
    Premix::sync::<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(())
}
```

## Book

For a longer-form guide, see `orm-book/` in this repository.

## SQL Transparency

Inspect the SQL generated by the query builder:

```rust
let query = User::find_in_pool(&pool).filter("age > 18").limit(10);
println!("{}", query.to_sql());
```

## Raw SQL Escape Hatch

Run raw SQL while mapping results to your model:

```rust
let users = User::raw_sql("SELECT * FROM users WHERE active = 1")
    .fetch_all(&pool)
    .await?;
```

## License

This project is licensed under the MIT license.