bb8-aykroyd

Crates.iobb8-aykroyd
lib.rsbb8-aykroyd
version0.3.1
sourcesrc
created_at2023-12-15 18:46:59.264859
updated_at2024-02-20 17:47:06.530367
descriptionAykroyd micro-ORM for the bb8 connection pool.
homepage
repositoryhttps://git.sr.ht/~couch/aykroyd
max_upload_size
id1071189
size5,680
Andrew Dona-Couch -- GitHub drop ICE (couchand)

documentation

https://docs.rs/bb8-aykroyd/latest/bb8_aykroyd/

README

bb8-aykroyd

Documentation

aykroyd support library for the bb8 connection pool.

Example

use bb8_aykroyd::AykroydConnectionManager;
use tokio_postgres::tls::NoTls;

#[derive(aykroyd::QueryOne)]
#[query(row(Row), text = "SELECT 1 + $1")]
struct AddOneTo(i32);

#[derive(aykroyd::FromRow)]
struct Row(i32);

#[tokio::main]
async fn main() {
    let manager = AykroydConnectionManager::new(
        "host=localhost user=postgres".parse().unwrap(),
        NoTls,
    );
    let pool = bb8::Pool::builder()
        .max_size(15)
        .build(manager)
        .await
        .unwrap();

    for i in 0..20 {
        let pool = pool.clone();
        tokio::spawn(async move {
            let client = pool.get().await.unwrap();

            let row = client.query_one(&AddOneTo(i)).await.unwrap();
            let value = row.0;
            assert_eq!(value, i + 1);
        });
    }
}
Commit count: 0

cargo fmt