29 lines
654 B
Rust
29 lines
654 B
Rust
|
pub mod accounts;
|
||
|
pub mod addresses;
|
||
|
|
||
|
pub use accounts::*;
|
||
|
pub use addresses::*;
|
||
|
use config::SharedAppConfig;
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
pub struct Database {
|
||
|
pub pool: sqlx::PgPool,
|
||
|
_config: SharedAppConfig,
|
||
|
}
|
||
|
|
||
|
impl Database {
|
||
|
pub async fn build(config: SharedAppConfig) -> Self {
|
||
|
let url = config.lock().account_manager().database_url.clone();
|
||
|
let pool = sqlx::PgPool::connect(&url).await.unwrap_or_else(|e| {
|
||
|
tracing::error!("Failed to connect to database. {e:?}");
|
||
|
std::process::exit(1);
|
||
|
});
|
||
|
Self {
|
||
|
pool,
|
||
|
_config: config,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn pool(&self) {}
|
||
|
}
|