ormer 0.2.8

A minimalist ORM framework that supports SQLite, PostgreSQL, MySQL, and SqlServer
docs.rs failed to build ormer-0.2.8
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: ormer-0.2.6

ormer

version status

English | 简体中文

A minimalist ORM framework that supports SQLite, PostgreSQL, MySQL, and SqlServer.

It also includes raw SQL and typed raw expression parameter binding, relation loading, object graph writes, tracked dirty-field saves, optimized batch insert/update paths, embedded value objects, decimal types, typed derived tables, model filters, dynamic table routing, hooks, global SQL trace callbacks, and versioned migration support.

Online Documentation

Quick Example

#[derive(Debug, ormer::Model)]
#[table = "users"]
struct User {
    #[primary(auto)]
    id: i32,
    name: String,
    age: i32,
    email: Option<String>,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // connect to database and create table
    let db = ormer::Database::connect(ormer::DbType::Sqlite, ":memory:").await?;
    db.create_table::<User>().execute().await?;

    // insert data
    db.insert(&User {
        id: 1,
        name: "Alice".to_string(),
        age: 18,
        email: None,
    })
    .execute()
    .await?;

    // query data
    let users = db
        .select::<User>()
        .filter(|p| p.age.ge(18))
        .collect::<Vec<_>>()
        .await?;
    println!("users: {users:?}");

    Ok(())
}