diff --git a/src/core/images.rs b/src/core/images.rs index a06ab61..e0d78bf 100644 --- a/src/core/images.rs +++ b/src/core/images.rs @@ -159,21 +159,21 @@ impl Model { pub async fn append_image( &mut self, image: Image, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { todo!() } pub async fn new_image( &mut self, - db: PoolConnection, + db: &SqlitePool, ) -> Result { todo!() } pub async fn update_image( &mut self, image: Image, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { let id = image.id; self.update_item(image.clone(), |current_image| { @@ -184,7 +184,6 @@ impl Model { .to_str() .map(std::string::ToString::to_string) .unwrap_or_default(); - let mut db = db.detach(); debug!(?image, "should be been updated"); let result = query!( r#"UPDATE images SET title = $2, file_path = $3 WHERE id = $1"#, @@ -192,7 +191,7 @@ impl Model { image.title, path, ) - .execute(&mut db) + .execute(db) .await.into_diagnostic(); match result { @@ -210,11 +209,11 @@ impl Model { pub async fn remove_image( &mut self, id: i32, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { self.remove_item(|image| image.id == id)?; query!("DELETE FROM images WHERE id = $1", id) - .execute(&mut db.detach()) + .execute(db) .await .into_diagnostic() .map(|_| ()) diff --git a/src/core/presentations.rs b/src/core/presentations.rs index ce4dcac..f02b53b 100644 --- a/src/core/presentations.rs +++ b/src/core/presentations.rs @@ -301,14 +301,14 @@ impl Model { pub async fn append_presentation( &mut self, presentation: Presentation, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { todo!() } pub async fn new_presentation( &mut self, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { todo!() } @@ -316,14 +316,14 @@ impl Model { pub async fn update_presentation( &mut self, presentation: Presentation, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { todo!() } pub async fn remove_presentation( &mut self, id: i32, - db: PoolConnection, + db: &SqlitePool, ) -> Result<()> { todo!() } diff --git a/src/core/videos.rs b/src/core/videos.rs index 05bfaa1..e91b93b 100644 --- a/src/core/videos.rs +++ b/src/core/videos.rs @@ -201,22 +201,19 @@ impl Model