From df2d2b66bee97077df4f530ca74f28bf9b6ed2a7 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 11:52:28 +0100 Subject: [PATCH] Can delete all the likes of a given user --- src/helpers/AccountHelper.ts | 3 +++ src/helpers/LikesHelper.ts | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index ecd0ff9..b7ebe01 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -453,6 +453,9 @@ export class AccountHelper { // Delete all responses of user to surveys await SurveyHelper.DeleteAllUserResponses(userID); + + // Delete all the likes created by the user + await LikesHelper.DeleteAllUser(userID); */ // TODO : continue work diff --git a/src/helpers/LikesHelper.ts b/src/helpers/LikesHelper.ts index e031923..cefe746 100644 --- a/src/helpers/LikesHelper.ts +++ b/src/helpers/LikesHelper.ts @@ -135,6 +135,17 @@ export class LikesHelper { })).map(this.DBToUserLike); } + /** + * Delete all the likes of a given user + * + * @param userID Target user ID + */ + public static async DeleteAllUser(userID: number) { + await DatabaseHelper.DeleteRows(LIKES_TABLE, { + ID_personne: userID + }) + } + /** * Turn a database entry into a like entry *