diff --git a/mediarepo-daemon/mediarepo-database/src/database.rs b/mediarepo-daemon/mediarepo-database/src/database.rs deleted file mode 100644 index 43c4ab8..0000000 --- a/mediarepo-daemon/mediarepo-database/src/database.rs +++ /dev/null @@ -1,20 +0,0 @@ -use sea_orm::{DatabaseConnection, Database}; -use mediarepo_core::error::{RepoDatabaseResult}; - -pub struct RepoDatabase { - connection: DatabaseConnection, -} - -impl RepoDatabase { - /// Creates a new repo database from an existing connection - pub(crate) fn new(connection: DatabaseConnection) -> Self { - Self {connection} - } - - /// Creates a new Repo Database Connection - pub(crate) async fn connect>(uri: S) -> RepoDatabaseResult { - let connection = Database::connect(uri.as_ref()).await?; - - Ok(Self::new(connection)) - } -} \ No newline at end of file diff --git a/mediarepo-daemon/mediarepo-database/src/lib.rs b/mediarepo-daemon/mediarepo-database/src/lib.rs index cbb6969..60f2078 100644 --- a/mediarepo-daemon/mediarepo-database/src/lib.rs +++ b/mediarepo-daemon/mediarepo-database/src/lib.rs @@ -1,13 +1,16 @@ use mediarepo_core::error::{RepoDatabaseResult}; use crate::database::RepoDatabase; +use sea_orm::{DatabaseConnection, Database}; + -pub mod database; pub mod entities; /// Connects to the database, runs migrations and returns the RepoDatabase wrapper type -pub async fn get_database>(uri: S) -> RepoDatabaseResult { +pub async fn get_database>(uri: S) -> RepoDatabaseResult { migrate(uri.as_ref()).await?; - RepoDatabase::connect(uri).await + let conn = Database::connect(uri).await?; + + Ok(conn) } async fn migrate(uri: &str) -> RepoDatabaseResult<()> {