// database
Database Layer
Auto-sized connection pool + dynamic query executor + tight floz ORM integration.
Connection Pool
let pool: DbPool = pool(0).await; // auto-sized from CPU count
let pool = pool_with_options(&PoolOptions {
min_connections: 4, max_connections: 20,
acquire_timeout_secs: 30,
idle_timeout_secs: 600, max_lifetime_secs: 1800,
}).await;
Dynamic Query Execution
let users: Vec<User> = execute_query(
"SELECT * FROM users WHERE age > 25".into(), &pool,
).await?;
let json: String = execute_query_json(query, &pool).await?;
let user: User = execute_one_query(query, &pool).await?;
ORM Integration: floz ORM is re-exported via use floz::prelude::*. Use #[model("table_name", crud(path = "/..."))] to define database models that additionally automatically generate full REST CRUD APIs and OpenAPI endpoints natively.
Database Migrations
CLI Integration: Use floz db generate to snapshot model structs, and floz db migrate to synchronize your live environment via structural fingerprinting engine!
use floz::prelude::*;
embed_migrations!(); // Embeds snapshots securely via zero-hit static compilation.