From 9ca8641f207a45b2f808454719da9f30f13dafcb Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sat, 20 Nov 2021 22:20:38 -0700 Subject: [PATCH] Create function to remove games from database --- database/scores/games.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/database/scores/games.js b/database/scores/games.js index 256919b..c0ad895 100644 --- a/database/scores/games.js +++ b/database/scores/games.js @@ -23,4 +23,12 @@ async function add(divisionID, seasonID, date, team1ID, team2ID, team1Score, tea RETURNING game_id;`; const id = (await database.executeQuery(query, [divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score]))[0][0]; return new Game(id, date, team1ID, team2ID, team1Score, team2Score); +} + +async function remove(id) { + const query = `DELETE FROM scores.games + WHERE game_id = $1 + RETURNING * ;`; + const row = (await database.executeQuery(query, [id]))[0]; + return new Game(id, row[3], row[4], row[5], row[6], row[7]); } \ No newline at end of file