1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 21:39:21 +00:00

Remove all movies

This commit is contained in:
Pierre HUBERT 2021-02-13 10:34:30 +01:00
parent 42bff295d1
commit 6396271e9c
2 changed files with 13 additions and 1 deletions

View File

@ -17,6 +17,12 @@ pub fn get_list_user(user_id: &UserID) -> ResultBoxError<Vec<Movie>> {
.exec(db_to_movie) .exec(db_to_movie)
} }
/// Get all movies
pub fn get_all() -> ResultBoxError<Vec<Movie>> {
database::QueryInfo::new(MOVIES_TABLE)
.exec(db_to_movie)
}
/// Get information about a single movie /// Get information about a single movie
pub fn get_info(movie_id: u64) -> ResultBoxError<Movie> { pub fn get_info(movie_id: u64) -> ResultBoxError<Movie> {
database::QueryInfo::new(MOVIES_TABLE) database::QueryInfo::new(MOVIES_TABLE)

View File

@ -1,6 +1,6 @@
use comunic_server::controllers::server; use comunic_server::controllers::server;
use comunic_server::data::config::{conf, Config}; use comunic_server::data::config::{conf, Config};
use comunic_server::helpers::database; use comunic_server::helpers::{database, movies_helper};
#[actix_rt::main] #[actix_rt::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
@ -15,6 +15,12 @@ async fn main() -> std::io::Result<()> {
// Connect to the database // Connect to the database
database::connect(&conf().database).expect("Could not connect to 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 // Start the server
server::start_server(conf()).await server::start_server(conf()).await
} }