Skip to main content

Crate magic_orm

Crate magic_orm 

Source
Expand description

§MagicORM

A Rust ORM for SQL databases with a focus on ease of use, low boilerplate, and performance. Built for fast-evolving systems where models, fields, and relationships change constantly.

  • Backends: SQLite (default) and PostgreSQL
  • Schema: automatic table creation, introspection, and migrations
  • Queries: typed QueryBuilder, filters, joins, eager loading
  • Scale: batch insertion, streaming, keyset pagination, retention helpers

§Quickstart

use magic_orm::{prelude::*, register_models};

#[derive(MagicModel, Debug)]
#[magic(table = "users")]
pub struct User {
    pub id: i64,
    pub name: String,
}

register_models!(User);

let pool = Sqlite::pool("app.db").await?;
create_all::<_, AppModels>(&pool).await?;

let id = User::insert(&pool, &User::new("Alicia".into())).await?;
let user = User::get_by_id(&pool, id).await?.unwrap();
assert_eq!(user.name, "Alicia");

See the repository README and docs/ for guides and architecture decisions.

Modules§

crud
db
describe
dialect
model
prelude
query
relations
schema
sqlite

Macros§

has_many
register_models
Registra todos los modelos de la aplicación y genera la struct AppModels que implementa crate::model::RegisteredModels y describe todos los modelos.

Derive Macros§

MagicModel