Add function to retrieve teams by sport
parent
16c90cf883
commit
e37b10596e
|
@ -36,3 +36,17 @@ async function remove(id) {
|
|||
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;
|
||||
}
|
Reference in New Issue