Add function to retrieve teams by sport
This commit is contained in:
parent
16c90cf883
commit
e37b10596e
1 changed files with 14 additions and 0 deletions
|
@ -36,3 +36,17 @@ async function remove(id) {
|
||||||
name = (await database.executeQuery(query, [id]))[0][0];
|
name = (await database.executeQuery(query, [id]))[0][0];
|
||||||
return new Team(id, name);
|
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 a new issue