Skip to content
프로젝트

소개

Rust용 비동기 ORM

데이터 및 분석

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+3
in 7 days
+17
in 15 days
+23
in 1 month
+71

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Toasty

The cozy, easy ORM for Rust

Guide • API Docs • Crates.io • Discord

Crates.io MIT licensed Build Status Discord chat

Toasty supports SQL databases (SQLite/Turso, PostgreSQL, MySQL) and DynamoDB. It does not hide database capabilities — it exposes features based on the target database.

Using Toasty

You will define your data model using Rust structs annotated with the #[derive(toasty::Model)] derive macro. Runnable examples live in the examples/ directory; the snippets below illustrate the basics.

#[derive(Debug, toasty::Model)]
struct User {
    #[key]
    #[auto]
    id: u64,

    name: String,

    #[unique]
    email: String,

    #[has_many]
    todos: toasty::Deferred<Vec<Todo>>,
}

#[derive(Debug, toasty::Model)]
struct Todo {
    #[key]
    #[auto]
    id: u64,

    #[index]
    user_id: u64,

    #[belongs_to]
    user: toasty::Deferred<User>,

    title: String,
}

Then, you can easily work with the data model:

// Create a new user and give them some todos.
let user = toasty::create!(User {
    name: "John Doe",
    email: "[email protected]",
    todos: [
        { title: "Make pizza" },
        { title: "Finish Toasty" },
        { title: "Sleep" },
    ],
}).exec(&mut db).await?;

// Load the user from the database
let user = User::get_by_id(&mut db, &user.id).await?;

// Load and iterate the user's todos
let todos = user.todos().exec(&mut db).await?;

for todo in &todos {
    println!("{:#?}", todo);
}

SQL and NoSQL

Toasty supports both SQL and NoSQL databases. Current drivers are SQLite, Turso, PostgreSQL, MySQL, and DynamoDB. However, it does not aim to abstract the database. Instead, Toasty leans into the target database's capabilities and aims to help the user avoid issuing inefficient queries for that database.

When targeting both SQL and NoSQL databases, Toasty generates query methods (e.g. get_by_id only for access patterns that are indexed). When targeting a SQL database, Toasty might allow arbitrary additional query constraints. When targeting a NoSQL database, Toasty will only allow constraints that the specific target database can execute. For example, with DynamoDB, query methods might be generated based on the table's primary key, and additional constraints may be set for the sort key.

Application data model vs. database schema

Toasty decouples the application data model from the database's schema. By default, a toasty application schema will map 1-1 with a database schema. However, additional annotations may be specified to customize how the application data model maps to the database schema.

Roadmap

Development priorities are based on feedback and contributions. If you run into missing features or rough edges, please open an issue or submit a pull request. Planned work lives under docs/dev/roadmap.md.

Contributing

See CONTRIBUTING.md. Small fixes can go straight to a PR; larger changes follow a lightweight propose → roadmap + design doc → implement flow.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Toasty by you, shall be licensed as MIT, without any additional terms or conditions.

관련 프로젝트 살펴보기

불러오는 중…