Add function to retrieve all sports from database
parent
c176e27987
commit
2d14395b61
|
@ -35,6 +35,19 @@ async function remove(id) {
|
|||
return new Sport(id, name);
|
||||
}
|
||||
|
||||
async function retrieveAll() {
|
||||
query = `SELECT *
|
||||
FROM scores.sports
|
||||
ORDER BY sport_name;`;
|
||||
const table = await database.executeQuery(query);
|
||||
|
||||
const sportsList = [];
|
||||
table.forEach((row) => {
|
||||
sportsList.push(new Sport(row[0], row[1]));
|
||||
});
|
||||
return sportsList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -42,3 +55,4 @@ async function remove(id) {
|
|||
exports.create = create;
|
||||
exports.rename = rename;
|
||||
exports.remove = remove;
|
||||
exports.retrieveAll = retrieveAll;
|
Reference in New Issue