13 releases

0.5.0 Mar 27, 2022
0.4.2 Jan 20, 2021
0.3.3 Apr 20, 2020
0.2.1 Mar 28, 2020
0.1.0 Jan 25, 2020

#1952 in Database interfaces

Download history 11/week @ 2023-10-02 12/week @ 2023-10-09 12/week @ 2023-10-16 18/week @ 2023-10-23 35/week @ 2023-10-30 17/week @ 2023-11-06 26/week @ 2023-11-13 40/week @ 2023-11-20 53/week @ 2023-11-27 7/week @ 2023-12-04 11/week @ 2023-12-11 25/week @ 2023-12-18 37/week @ 2023-12-25 19/week @ 2024-01-01 14/week @ 2024-01-08 13/week @ 2024-01-15

85 downloads per month
Used in 2 crates

MIT license

45KB
1.5K SLoC

debil debil at crates.io

ORM aims to provide Table macro and auto migration

Table macro

You need to specify sql_type to be something that each DB crate provides.

#[derive(Table)]
#[sql(table_name = "ex_1", sql_type = "...", primary_key = "pk")]
struct Ex1 {
    #[sql(size = 50, unique = true, not_null = true)]
    field1: String,
    aaaa: i32,
    pk: i32,
}

This example derives some useful mapper functions for this struct. See functions in debil's docs.

Accessor macro

Accessor macro provides safe way to access to each column. This is useful for constructing a query.

// Use Accessor derive here!
#[derive(Table, Accessor)]
#[sql(table_name = "ex_1", sql_type = "...", primary_key = "pk")]
struct Ex1 {
    field1: String,
    aaaa: i32,
    pk: i32,
}

// Use accessor! macro to access to a field with table_name prefixed
assert_eq!(accessor!(Ex1::field1), "ex_1.field1");

// If you only need field name, use accessor_name! macro
assert_eq!(accessor_name!(Ex1::aaaa), "aaaa");

// Or you can just call the field name function directly, which is derived by Accessor derive
assert_eq!(Ex1::field1(), "field1");

// accessor!(Ex1::foobar) <- compile error!

Dependencies

~3–20MB
~285K SLoC