vyuh 0.2.2

Vyuh web framework for Axum and SQLx with handler-first APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use sqlx::Row as _;
use vyuh::db::{DbConf, DbPool};

#[tokio::main]
async fn main() -> Result<(), vyuh::db::DbError> {
    let conf = DbConf::from_env()?;
    let pool = DbPool::from_conf(&conf).await?;

    let row = sqlx::query("SELECT COUNT(*) AS total FROM notes")
        .fetch_one(pool.as_sqlx())
        .await?;
    let total: i64 = row.try_get("total")?;

    println!("notes: {total}");
    Ok(())
}