Create function to retrive seasons

main
sudoer777 2021-11-20 21:57:27 -07:00
parent e9bda3c807
commit c046eeb6ac
1 changed files with 13 additions and 0 deletions

View File

@ -27,4 +27,17 @@ async function remove(id) {
RETURNING school_year;`;
const year = (await database.executeQuery(query, [id]))[0][0];
return new Season(id, year);
}
async function retrieveAll() {
const query = `SELECT *
FROM scores.seasons
ORDER BY school_year;`;
const table = await database.executeQuery(query);
const seasonsList = [];
table.forEach((row) => {
seasonsList.push(new Season(row[0], row[1]));
});
return seasonsList;
}