diff --git a/database/scores/teams.js b/database/scores/teams.js index 3e09496..fe27d6b 100644 --- a/database/scores/teams.js +++ b/database/scores/teams.js @@ -35,4 +35,18 @@ async function remove(id) { RETURNING team_name;`; name = (await database.executeQuery(query, [id]))[0][0]; return new Team(id, name); +} + +async function retrieveBySport(sportID) { + query = `SELECT * + FROM scores.teams + WHERE sport_id = $1 + ORDER BY team_name;`; + const table = await database.executeQuery(query); + + const teamsList = []; + table.forEach((row) => { + teamsList.push(new Team(row[0], row[1])); + }); + return teamsList; } \ No newline at end of file