progress-pile/progress-pile-core/src/global/database.rs

14 lines
470 B
Rust
Raw Normal View History

2025-05-12 08:49:51 +09:00
use crate::error::Error;
2025-05-12 20:29:46 +09:00
use sea_orm::{ConnectOptions, Database, DatabaseConnection, DbErr};
2025-05-12 08:49:51 +09:00
2025-05-12 20:29:46 +09:00
pub trait GlobalDatabase {
fn get_database(&self) -> Option<&DatabaseConnection>;
async fn get_or_try_init_database(&self) -> Result<&DatabaseConnection, Error>;
async fn get_or_try_init_database_with_connect_options<T>(&self, options: T) -> Result<&DatabaseConnection, Error> where
2025-05-12 20:29:46 +09:00
T: Into<ConnectOptions>;
2025-05-12 08:49:51 +09:00
}
#[cfg(test)]
mod tests {
use super::*;
}