roa-diesel 0.6.0

diesel integration with roa framework
docs.rs failed to build roa-diesel-0.6.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: roa-diesel-0.5.0

Stable Test codecov Rust Docs Crate version Download License: MIT

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;
use roa_diesel::preload::*;
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.