Expand description
Helge is a tiny wrapper around r2d2::Pool and diesel ConnectionManager to provide a simple way to use diesel postgres with r2d2 in an async context.
Example
use diesel::prelude::*;
use helge::{Error, Helge};
diesel::table! {
users {
id -> Integer,
name -> Varchar,
}
}
#[derive(Debug, Insertable)]
#[diesel(table_name = users)]
struct NewUser {
name: String,
}
async fn query() -> Result<(), helge::Error> {
let helge = Helge::<diesel::PgConnection>::new("postgres://localhost/somedatabase")
.expect("connecting Helge");
helge.query(|conn| {
diesel::insert_into(users::table)
.values(&NewUser {
name: String::from("Helge"),
})
.execute(conn)
}).await;
Ok(())
}
Structs
- The main wrapper, simply contains an r2d2::Pool
Enums
- ConnectionError can only occur when creating Helge.
- General Errors that can occur when running queries using Helge.