From 7e07236779421710d06b8559e7a5ba4c5c1a7d1e Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sat, 20 Nov 2021 21:38:08 -0700 Subject: [PATCH] Add function to rename teams --- database/scores/teams.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/database/scores/teams.js b/database/scores/teams.js index 8d9858b..53450fd 100644 --- a/database/scores/teams.js +++ b/database/scores/teams.js @@ -19,4 +19,12 @@ async function create(name, sportID) { RETURNING team_id;`; const id = (await database.executeQuery(query, [name, sportID]))[0][0]; return new Team(id, name); +} + +async function rename(id, name) { + query = `UPDATE scores.teams + SET team_name = $2 + WHERE team_id = $1;`; + await database.executeQuery(query, [id, name]); + return new Team(id, name); } \ No newline at end of file