Add "const" to accidental global variables
parent
e37b10596e
commit
e056743022
|
@ -21,7 +21,7 @@ function getGenderID(gender) {
|
||||||
|
|
||||||
|
|
||||||
async function create(name, gender, sportID) {
|
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)
|
VALUES($1,$2,$3)
|
||||||
RETURNING division_id;`;
|
RETURNING division_id;`;
|
||||||
const genderID = getGenderID(gender);
|
const genderID = getGenderID(gender);
|
||||||
|
@ -30,7 +30,7 @@ async function create(name, gender, sportID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rename(id, division) {
|
async function rename(id, division) {
|
||||||
query = `UPDATE scores.divisions
|
const query = `UPDATE scores.divisions
|
||||||
SET division_name = $2
|
SET division_name = $2
|
||||||
WHERE division_id = $1;`;
|
WHERE division_id = $1;`;
|
||||||
await database.executeQuery(query, [id, name]);
|
await database.executeQuery(query, [id, name]);
|
||||||
|
@ -38,15 +38,15 @@ async function rename(id, division) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(id) {
|
async function remove(id) {
|
||||||
query = `DELETE FROM scores.divisions
|
const query = `DELETE FROM scores.divisions
|
||||||
WHERE division_id = $1
|
WHERE division_id = $1
|
||||||
RETURNING division_name;`;
|
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);
|
return new Division(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieveBySportAndGender(sportID, gender) {
|
async function retrieveBySportAndGender(sportID, gender) {
|
||||||
query = `SELECT *
|
const query = `SELECT *
|
||||||
FROM scores.divisions
|
FROM scores.divisions
|
||||||
WHERE sport_id = $1 AND gender = $2
|
WHERE sport_id = $1 AND gender = $2
|
||||||
ORDER BY division_name;`;
|
ORDER BY division_name;`;
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Sport {
|
||||||
|
|
||||||
|
|
||||||
async function create(name) {
|
async function create(name) {
|
||||||
query = `INSERT INTO scores.sports(sport_name)
|
const query = `INSERT INTO scores.sports(sport_name)
|
||||||
VALUES($1)
|
VALUES($1)
|
||||||
RETURNING sport_id;`;
|
RETURNING sport_id;`;
|
||||||
const id = (await database.executeQuery(query, [name]))[0][0];
|
const id = (await database.executeQuery(query, [name]))[0][0];
|
||||||
|
@ -20,7 +20,7 @@ async function create(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rename(id, name) {
|
async function rename(id, name) {
|
||||||
query = `UPDATE scores.sports
|
const query = `UPDATE scores.sports
|
||||||
SET sport_name = $2
|
SET sport_name = $2
|
||||||
WHERE sport_id = $1;`;
|
WHERE sport_id = $1;`;
|
||||||
await database.executeQuery(query, [id, name]);
|
await database.executeQuery(query, [id, name]);
|
||||||
|
@ -28,15 +28,15 @@ async function rename(id, name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(id) {
|
async function remove(id) {
|
||||||
query = `DELETE FROM scores.sports
|
const query = `DELETE FROM scores.sports
|
||||||
WHERE sport_id = $1
|
WHERE sport_id = $1
|
||||||
RETURNING sport_name;`;
|
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);
|
return new Sport(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieveAll() {
|
async function retrieveAll() {
|
||||||
query = `SELECT *
|
const query = `SELECT *
|
||||||
FROM scores.sports
|
FROM scores.sports
|
||||||
ORDER BY sport_name;`;
|
ORDER BY sport_name;`;
|
||||||
const table = await database.executeQuery(query);
|
const table = await database.executeQuery(query);
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Team {
|
||||||
|
|
||||||
|
|
||||||
async function create(name, sportID) {
|
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)
|
VALUES($1, $2)
|
||||||
RETURNING team_id;`;
|
RETURNING team_id;`;
|
||||||
const id = (await database.executeQuery(query, [name, sportID]))[0][0];
|
const id = (await database.executeQuery(query, [name, sportID]))[0][0];
|
||||||
|
@ -22,7 +22,7 @@ async function create(name, sportID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rename(id, name) {
|
async function rename(id, name) {
|
||||||
query = `UPDATE scores.teams
|
const query = `UPDATE scores.teams
|
||||||
SET team_name = $2
|
SET team_name = $2
|
||||||
WHERE team_id = $1;`;
|
WHERE team_id = $1;`;
|
||||||
await database.executeQuery(query, [id, name]);
|
await database.executeQuery(query, [id, name]);
|
||||||
|
@ -30,15 +30,15 @@ async function rename(id, name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(id) {
|
async function remove(id) {
|
||||||
query = `DELETE FROM scores.teams
|
const query = `DELETE FROM scores.teams
|
||||||
WHERE team_id = $1
|
WHERE team_id = $1
|
||||||
RETURNING team_name;`;
|
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);
|
return new Team(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieveBySport(sportID) {
|
async function retrieveBySport(sportID) {
|
||||||
query = `SELECT *
|
const query = `SELECT *
|
||||||
FROM scores.teams
|
FROM scores.teams
|
||||||
WHERE sport_id = $1
|
WHERE sport_id = $1
|
||||||
ORDER BY team_name;`;
|
ORDER BY team_name;`;
|
||||||
|
|
Reference in New Issue