#derive #database #rust

macro db_meta_derive

db-meta-derive is a wrapper around PostgresSOL using tokio-postgres

1 unstable release

0.1.0 May 5, 2024

#990 in Data structures

Download history 155/week @ 2024-04-29 44/week @ 2024-05-06

199 downloads per month

MIT/Apache

18KB
413 lines

db-meta-derive

db-meta-derive is a wrapper around PostgresSOL using tokio-postgres.

Examples

Schema

#[derive(PostgresMapper, Deserialize, PostgresMeta)]
#[pg_mapper(table = "test")]
struct Test {
    #[id]
    id: i64,
    title: Option<String>,
    create_time: Option<SystemTime>,
    update_time: Option<SystemTime>,
}

Usage

pub fn test() {
    let meta = Test::meta();
    println!("{:?}", meta);
    // ("test", [("id", "bigserial primary key", 0, "", true), ("title", "varchar", 0, "", false), ("create_time", "timestamp", 0, "", false), ("update_time", "timestamp", 0, "", false)])
}

Dependencies

~2–3MB
~65K SLoC