1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 15:29:21 +00:00

Can delete all the movies of a user

This commit is contained in:
Pierre HUBERT 2021-01-21 18:30:20 +01:00
parent b8e9a4c95d
commit 64b9497cc5
2 changed files with 12 additions and 0 deletions

View File

@ -318,6 +318,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError {
// Delete all the likes created by the user // Delete all the likes created by the user
likes_helper::delete_all_user(user_id)?; likes_helper::delete_all_user(user_id)?;
// Delete all user movies
movies_helper::delete_all_user(user_id)?;
// TODO : continue work here // TODO : continue work here
Ok(()) Ok(())

View File

@ -43,6 +43,15 @@ pub fn delete(movie: &Movie) -> ResultBoxError {
.exec() .exec()
} }
/// Delete all the movies of a user
pub fn delete_all_user(user_id: &UserID) -> ResultBoxError {
for movie in &get_list_user(user_id)? {
delete(movie)?;
}
Ok(())
}
/// Turn a database entry into a movie object /// Turn a database entry into a movie object
fn db_to_movie(row: &database::RowResult) -> ResultBoxError<Movie> { fn db_to_movie(row: &database::RowResult) -> ResultBoxError<Movie> {
Ok(Movie { Ok(Movie {