Crates.io | tide-diesel |
lib.rs | tide-diesel |
version | 0.1.2 |
source | src |
created_at | 2022-02-07 15:52:47.259804 |
updated_at | 2022-02-15 01:10:03.79249 |
description | Tide middleware for Diesel pooled connections & transactions. |
homepage | |
repository | https://github.com/bluemoon/tide-diesel |
max_upload_size | |
id | 528493 |
size | 5,699 |
Tide middleware for Diesel pooled connections & transactions.
A Tide middleware which holds a pool of Diesel database connections, and automatically hands each tide::Request a connection, which may transparently be either a database transaction, or a direct pooled database connection.
When using this, use the DieselRequestExt
extenstion trait to get the connection.
#[async_std::main]
async fn main() -> anyhow::Result<()> {
use tide_diesel::DieselRequestExt;
let mut app = tide::new();
app.with(DieselMiddleware::new("postgres://localhost/a_database").await?);
app.at("/").post(|req: tide::Request<()>| async move {
let mut pg_conn = req.pg_conn().await;
Ok("")
});
Ok(())
}
Licensed under the BlueOak Model License 1.0.0 — Contributions via DCO 1.1