ignis-db 0.2.0

A comprehensive PostgreSQL ORM with macro-driven schema management
Documentation
//! Simple example demonstrating the table! macro

use ignis_db::{table, IgnisObject};

// Define a users table
table! {
    users (id) {
        id -> Int4,
        email -> Varchar,
        name -> Text,
        created_at -> Timestamptz,
        active -> Bool,
    }
}

// Define a posts table
table! {
    posts (id) {
        id -> Int4,
        user_id -> Int4,
        title -> Varchar,
        content -> Text,
        published -> Bool,
        created_at -> Timestamptz,
    }
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    println!("Ignis Table Macro Example");
    println!("========================\n");

    // Test the users table
    let users_table = users::table();
    println!("Users table:");
    println!("  Name: {}", users_table.name);
    println!("  Primary Key: {:?}", users_table.primary_key);
    println!("  Columns: {}", users_table.columns.len());
    println!("  DDL: {}", users_table.generate_ddl());
    println!();

    // Test the posts table
    let posts_table = posts::table();
    println!("Posts table:");
    println!("  Name: {}", posts_table.name);
    println!("  Primary Key: {:?}", posts_table.primary_key);
    println!("  Columns: {}", posts_table.columns.len());
    println!("  DDL: {}", posts_table.generate_ddl());
    println!();

    // Test column accessors
    println!("Column accessors:");
    println!("  users::id(): {}", users::id().name);
    println!("  users::email(): {}", users::email().name);
    println!("  users::name(): {}", users::name().name);
    println!("  posts::title(): {}", posts::title().name);
    println!("  posts::content(): {}", posts::content().name);
    println!();

    // Test inventory registration
    println!("Registered tables:");
    for table in ignis_db::get_registered_tables() {
        println!("  - {} ({})", table.0.name, table.0.object_type());
        println!("    DDL: {}", table.0.ddl);
    }

    Ok(())
}