Add function to retrieve all sports from database

main
sudoer777 2021-11-20 18:07:37 -07:00
parent c176e27987
commit 2d14395b61
1 changed files with 15 additions and 1 deletions

View File

@ -35,10 +35,24 @@ 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;
}
exports.create = create;
exports.rename = rename;
exports.remove = remove;
exports.remove = remove;
exports.retrieveAll = retrieveAll;