feat: add in database support

This commit is contained in:
Radical 2025-04-29 21:53:49 +02:00
parent bebad3be9b
commit 26b6601f5b
2 changed files with 28 additions and 1 deletions

View file

@ -1,5 +1,6 @@
use crate::Error;
use serde::Deserialize;
use sqlx::postgres::PgConnectOptions;
use tokio::fs::read_to_string;
#[derive(Debug, Deserialize)]
@ -12,7 +13,7 @@ pub struct ConfigBuilder {
pub struct Database {
username: String,
password: String,
hostname: String,
host: String,
database: String,
port: u16,
}
@ -67,3 +68,14 @@ pub struct Web {
pub port: u16,
pub ssl: bool,
}
impl Database {
pub fn connect_options(&self) -> PgConnectOptions {
PgConnectOptions::new()
.database(&self.database)
.host(&self.host)
.username(&self.username)
.password(&self.password)
.port(self.port)
}
}