Macro pg_worm::register

source ·
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<M> function.

If a table with the same name already exists, it is dropped.

Returns an error if:

  • the client is not connected
  • the creation of the table fails

Usage

use pg_worm::{Model, register};

#[derive(Model)]
struct Foo {
    #[column(primary_ley)]
    id: i64
}

#[tokio::main]
async fn main() -> Result<(), pg_worm::Error> {
    // ---- snip connection setup ----
    register!(Model).await?;
}