Rustango docs

Quickstart

Your first model, migration, and server in five minutes.

Define a model

Every table is a #[derive(Model)] struct. Auto<T> marks DB-assigned columns.

use rustango::Model;
use rustango::sql::Auto;

#[derive(Model)]
#[rustango(table = "post")]
pub struct Post {
    #[rustango(primary_key)]
    pub id: Auto<i64>,
    #[rustango(max_length = 200)]
    pub title: String,
    pub body: String,
}

Migrate & query

cargo run -- makemigrations
cargo run -- migrate
let recent = Post::objects()
    .order_by(&[("id", true)])
    .limit(10)
    .fetch(&pool)
    .await?;

Admin for free

Register the model with the admin builder and you get list/detail/edit CRUD at /admin with zero extra code.