Derive Macro geekorm_derive::GeekTable

source ·
#[derive(GeekTable)]
{
    // Attributes available to this derive:
    #[geekorm]
}
Expand description

Derive macro for GeekTable trait.

This macro will generate the implementation of GeekTable trait for the given struct. The struct must have named fields.

§Example

This macro generates a number of methods for the struct, including table and table_name methods.

use geekorm::{GeekTable, PrimaryKeyInteger};
use geekorm::prelude::*;

#[derive(GeekTable)]
struct Users {
    id: PrimaryKeyInteger,
    name: String,
    age: i32,
    occupation: String,
}

// This will get you the underlying table information.
let table = Users::table();
assert_eq!(Users::table_name(), "Users");