diff --git a/src/helpers/movies_helper.rs b/src/helpers/movies_helper.rs index 1178116..79e6810 100644 --- a/src/helpers/movies_helper.rs +++ b/src/helpers/movies_helper.rs @@ -17,6 +17,12 @@ pub fn get_list_user(user_id: &UserID) -> ResultBoxError> { .exec(db_to_movie) } +/// Get all movies +pub fn get_all() -> ResultBoxError> { + database::QueryInfo::new(MOVIES_TABLE) + .exec(db_to_movie) +} + /// Get information about a single movie pub fn get_info(movie_id: u64) -> ResultBoxError { database::QueryInfo::new(MOVIES_TABLE) diff --git a/src/main.rs b/src/main.rs index 3ad1933..5b9cb74 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use comunic_server::controllers::server; use comunic_server::data::config::{conf, Config}; -use comunic_server::helpers::database; +use comunic_server::helpers::{database, movies_helper}; #[actix_rt::main] async fn main() -> std::io::Result<()> { @@ -15,6 +15,12 @@ async fn main() -> std::io::Result<()> { // Connect to the database database::connect(&conf().database).expect("Could not connect to database!"); + // TODO : remove after application + // Remove all movies + for movie in movies_helper::get_all().unwrap() { + movies_helper::delete(&movie).unwrap(); + } + // Start the server server::start_server(conf()).await }