| Crates.io | armature-diesel |
| lib.rs | armature-diesel |
| version | 0.1.0 |
| created_at | 2025-12-27 03:08:34.80837+00 |
| updated_at | 2025-12-27 03:08:34.80837+00 |
| description | Diesel async database integration for the Armature framework |
| homepage | https://pegasusheavy.github.io/armature |
| repository | https://github.com/pegasusheavy/armature |
| max_upload_size | |
| id | 2006625 |
| size | 92,428 |
Diesel async database integration for the Armature framework.
[dependencies]
armature-diesel = "0.1"
use armature_diesel::{Pool, establish_pool};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pool = establish_pool("postgres://localhost/mydb").await?;
// Query
let users = pool.interact(|conn| {
users::table.load::<User>(conn)
}).await??;
// Transaction
pool.transaction(|conn| {
diesel::insert_into(users::table)
.values(&new_user)
.execute(conn)?;
diesel::insert_into(profiles::table)
.values(&profile)
.execute(conn)
}).await??;
Ok(())
}
let pool = Pool::builder()
.max_size(20)
.min_idle(5)
.connection_timeout(Duration::from_secs(5))
.build("postgres://localhost/mydb")
.await?;
MIT OR Apache-2.0