generated from t/malachite
29 lines
786 B
Rust
29 lines
786 B
Rust
mod sql;
|
|
|
|
use crate::config::Config;
|
|
use oiseau::{execute, postgres::DataManager as OiseauManager, postgres::Result as PgResult};
|
|
use tetratto_core::model::{Error, Result};
|
|
|
|
pub const NAME_REGEX: &str = r"[^\w_\-\.,!]+";
|
|
|
|
#[derive(Clone)]
|
|
pub struct DataManager(pub OiseauManager<Config>);
|
|
|
|
impl DataManager {
|
|
/// Create a new [`DataManager`].
|
|
pub async fn new(config: Config) -> PgResult<Self> {
|
|
Ok(Self(OiseauManager::new(config).await?))
|
|
}
|
|
|
|
/// Initialize tables.
|
|
pub async fn init(&self) -> Result<()> {
|
|
let conn = match self.0.connect().await {
|
|
Ok(c) => c,
|
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
|
};
|
|
|
|
// execute!(&conn, sql::CREATE_TABLE_ENTRIES).unwrap();
|
|
|
|
Ok(())
|
|
}
|
|
}
|