macro_rules! register { ($($x:ty),+) => { ... }; }
Expand description
Registers a Model with the database by creating a
corresponding table.
This is just a more convenient version api
for the register_model function.
This macro, too, requires the tokio crate.
Returns an error if:
- a table with the same name already exists,
- the client is not connected,
- the creation of the table fails
Usage
ⓘ
use pg_worm::{Model, register};
#[derive(Model)]
struct Foo {
#[column(primary_key)]
id: i64
}
#[tokio::main]
async fn main() -> Result<(), pg_worm::Error> {
// ---- snip connection setup ----
register!(Foo)?;
}