roy-ganz / toql

A friendly and productive ORM
50 stars 1 forks source link
database orm rust

Toql - A friendly and productive ORM

Tests Current Crates.io Version

Beginner Guide | API documentation

Toql is an ORM for async databases that features

It currently only supports MySQL. More are coming, promised :)

Installation

Add this to your Cargo.toml:

[dependencies]
toql = {version = "0.4", features = ["serde"]}
toql_mysql_async = "0.4"

Look And Feel

Derive your structs:

#[derive(Toql)]
#[toql(auto_key)]
struct Todo {
    #[toql(key)]
    id: u64,
    what: String,

    #[toql(join)]
    user: User 
}

And do stuff with them:

let toql = ...
let todo = Todo{ ... };

// Insert todo and update its generated id
toql.insert_one(&mut todo, paths!(top)).await?; 

// Compile time checked queries!
let q = query!(Todo, "*, user_id eq ?", &todo.user.id); 

// Typesafe loading
let todos = toql.load_many(q).await?; 

Quick start

Check out the CRUD example.

Contribution

Comments, bug fixes and quality improvements are welcome.

License

Toql is distributed under the terms of both the MIT license and the Apache License (Version 2.0).