Create function to remove games from database

main
sudoer777 2021-11-20 22:20:38 -07:00
parent acb987ffd4
commit 9ca8641f20
1 changed files with 8 additions and 0 deletions

View File

@ -23,4 +23,12 @@ async function add(divisionID, seasonID, date, team1ID, team2ID, team1Score, tea
RETURNING game_id;`; RETURNING game_id;`;
const id = (await database.executeQuery(query, [divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score]))[0][0]; const id = (await database.executeQuery(query, [divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score]))[0][0];
return new Game(id, date, team1ID, team2ID, team1Score, team2Score); 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]);
} }