Add function to retrieve all sports from database
parent
c176e27987
commit
2d14395b61
|
@ -35,10 +35,24 @@ async function remove(id) {
|
||||||
return new Sport(id, name);
|
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.create = create;
|
||||||
exports.rename = rename;
|
exports.rename = rename;
|
||||||
exports.remove = remove;
|
exports.remove = remove;
|
||||||
|
exports.retrieveAll = retrieveAll;
|
Reference in New Issue