diff --git a/database/scores/divisions.js b/database/scores/divisions.js index 8c5510d..9003da9 100644 --- a/database/scores/divisions.js +++ b/database/scores/divisions.js @@ -21,7 +21,7 @@ function getGenderID(gender) { async function create(name, gender, sportID) { - query = `INSERT INTO scores.divisions(division_name,gender,sport_id) + const query = `INSERT INTO scores.divisions(division_name,gender,sport_id) VALUES($1,$2,$3) RETURNING division_id;`; const genderID = getGenderID(gender); @@ -30,7 +30,7 @@ async function create(name, gender, sportID) { } async function rename(id, division) { - query = `UPDATE scores.divisions + const query = `UPDATE scores.divisions SET division_name = $2 WHERE division_id = $1;`; await database.executeQuery(query, [id, name]); @@ -38,15 +38,15 @@ async function rename(id, division) { } async function remove(id) { - query = `DELETE FROM scores.divisions + const query = `DELETE FROM scores.divisions WHERE division_id = $1 RETURNING division_name;`; - name = (await database.executeQuery(query, [id]))[0][0]; + const name = (await database.executeQuery(query, [id]))[0][0]; return new Division(id, name); } async function retrieveBySportAndGender(sportID, gender) { - query = `SELECT * + const query = `SELECT * FROM scores.divisions WHERE sport_id = $1 AND gender = $2 ORDER BY division_name;`; diff --git a/database/scores/sports.js b/database/scores/sports.js index 38f35cf..c801612 100644 --- a/database/scores/sports.js +++ b/database/scores/sports.js @@ -12,7 +12,7 @@ class Sport { async function create(name) { - query = `INSERT INTO scores.sports(sport_name) + const query = `INSERT INTO scores.sports(sport_name) VALUES($1) RETURNING sport_id;`; const id = (await database.executeQuery(query, [name]))[0][0]; @@ -20,7 +20,7 @@ async function create(name) { } async function rename(id, name) { - query = `UPDATE scores.sports + const query = `UPDATE scores.sports SET sport_name = $2 WHERE sport_id = $1;`; await database.executeQuery(query, [id, name]); @@ -28,15 +28,15 @@ async function rename(id, name) { } async function remove(id) { - query = `DELETE FROM scores.sports + const query = `DELETE FROM scores.sports WHERE sport_id = $1 RETURNING sport_name;`; - name = (await database.executeQuery(query, [id]))[0][0]; + const name = (await database.executeQuery(query, [id]))[0][0]; return new Sport(id, name); } async function retrieveAll() { - query = `SELECT * + const query = `SELECT * FROM scores.sports ORDER BY sport_name;`; const table = await database.executeQuery(query); diff --git a/database/scores/teams.js b/database/scores/teams.js index fe27d6b..0bdb33d 100644 --- a/database/scores/teams.js +++ b/database/scores/teams.js @@ -14,7 +14,7 @@ class Team { async function create(name, sportID) { - query = `INSERT INTO scores.teams(team_name, sport_id) + const query = `INSERT INTO scores.teams(team_name, sport_id) VALUES($1, $2) RETURNING team_id;`; const id = (await database.executeQuery(query, [name, sportID]))[0][0]; @@ -22,7 +22,7 @@ async function create(name, sportID) { } async function rename(id, name) { - query = `UPDATE scores.teams + const query = `UPDATE scores.teams SET team_name = $2 WHERE team_id = $1;`; await database.executeQuery(query, [id, name]); @@ -30,15 +30,15 @@ async function rename(id, name) { } async function remove(id) { - query = `DELETE FROM scores.teams + const query = `DELETE FROM scores.teams WHERE team_id = $1 RETURNING team_name;`; - name = (await database.executeQuery(query, [id]))[0][0]; + const name = (await database.executeQuery(query, [id]))[0][0]; return new Team(id, name); } async function retrieveBySport(sportID) { - query = `SELECT * + const query = `SELECT * FROM scores.teams WHERE sport_id = $1 ORDER BY team_name;`;