Create function to remove games from database
parent
acb987ffd4
commit
9ca8641f20
|
@ -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]);
|
||||||
}
|
}
|
Reference in New Issue