Macro light_magic::db

source ยท
macro_rules! db {
    (
        $(
            $table:ident $(: [$($derive:ident),*])? => { $($field_name:ident : $field_ty:ty),* }
        ),* $(,)?
    ) => { ... };
}
Expand description

Creates the Database struct with the fitting logic. Use open for creating/opening one at a specified path or use open_in_memory to only use one in memory.

Lock the AtomicDatabase using read() / write() to access and change it values. The saving of changes will be applied after the used variables are dropped.

use light_magic::db;

db! {
    // `users` is the table name
    // `{...}` is the table data
    // the first field, like here `id`, is the `primary_key`
    user => { id: usize, name: String, kind: String },
    // using [...] after the table name you can add your own derives
    // like here `PartialEq`
    criminal: [PartialEq] => { user_name: String, entry: String }
}