gamenight/backend-actix/src/request/util.rs

14 lines
418 B
Rust

use actix_web::web;
use diesel::{r2d2::{PooledConnection, ConnectionManager}, PgConnection};
use crate::DbPool;
pub trait GetPgConnection {
fn get_conn(&self) -> PooledConnection<ConnectionManager<PgConnection>>;
}
impl GetPgConnection for web::Data<DbPool> {
fn get_conn(&self) -> PooledConnection<ConnectionManager<PgConnection>> {
self.get().expect("couldn't get db connection from pool")
}
}