[−][src]Crate roa_diesel
This crate provides diesel integration with roa framework.
AsyncPool
A context extension to access r2d2 pool asynchronously.
use roa::{Context, Result}; use diesel::sqlite::SqliteConnection; use roa_diesel::{Pool, AsyncPool}; use diesel::r2d2::ConnectionManager; #[derive(Clone)] struct State(Pool<SqliteConnection>); impl AsRef<Pool<SqliteConnection>> for State { fn as_ref(&self) -> &Pool<SqliteConnection> { &self.0 } } async fn get(ctx: Context<State>) -> Result { let conn = ctx.get_conn().await?; // handle conn Ok(()) }
SqlQuery
A context extension to execute diesel query asynchronously.
Refer to integration example for more use cases.
Modules
preload | preload ext traits. |
Structs
ConnectionManager | An r2d2 connection manager for use with Diesel. |
Functions
builder | Create a pool builder. |
make_pool | Create a connection pool. |
Type Definitions
Pool | An alias for r2d2::Pool<diesel::r2d2::ConnectionManager |
WrapConnection | An alias for r2d2::PooledConnection<diesel::r2d2::ConnectionManager |