#sql #table #definition #macro #helper #fields #sql-macros

macro sql-table-macros

Helper macros to generate SQL table definitions

2 releases

0.1.2 Nov 16, 2024
0.1.1 Nov 16, 2024
0.1.0 Nov 16, 2024

#929 in Rust patterns

Download history 307/week @ 2024-11-16 16/week @ 2024-11-23 29/week @ 2024-11-30 9/week @ 2024-12-07

361 downloads per month

MIT license

6KB
68 lines

sql-table-macros

Helper macros to auto add sql table common fields to struct definition

Example

#![allow(dead_code)]
use sql_table_macros::table_common_fields;

type Id = u64;

#[table_common_fields(Id, std::time::Duration)]
#[derive(Default, Debug)]
struct User {
    id: String,
    name: String,
}

fn main() {
    let user = User::default();
    assert_eq!(
        format!("{user:?}"),
        r#"User { id: "", name: "", created_by: 0, updated_by: 0, created_at: 0ns, updated_at: 0ns, is_deleted: false }"#
    );
}

Dependencies

~230–670KB
~16K SLoC