Skip to main content

check_models

Macro check_models 

Source
macro_rules! check_models {
    ($registry:expr, $($model:ty),+ $(,)?) => { ... };
}
Expand description

Check multiple models against a schema registry and return results.

This macro simplifies batch model validation by automatically checking each model’s generated SQL against the registry.

§Example

use pgorm::{check_models, SchemaRegistry, Model, FromRow};

#[derive(Debug, FromRow, Model)]
#[orm(table = "users")]
struct User { #[orm(id)] id: i64, name: String }

#[derive(Debug, FromRow, Model)]
#[orm(table = "orders")]
struct Order { #[orm(id)] id: i64, user_id: i64 }

let registry = SchemaRegistry::new();
// ... register tables ...

// Check all models at once
let results = check_models!(registry, User, Order);
for (name, issues) in &results {
    if issues.is_empty() {
        println!("✓ {}", name);
    } else {
        println!("✗ {} ({} issues)", name, issues.len());
    }
}