From c046eeb6acd42f2e17fd8698ea3e3a9cabc73f96 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sat, 20 Nov 2021 21:57:27 -0700 Subject: [PATCH] Create function to retrive seasons --- database/scores/seasons.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/database/scores/seasons.js b/database/scores/seasons.js index 55e9941..b8ff917 100644 --- a/database/scores/seasons.js +++ b/database/scores/seasons.js @@ -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; } \ No newline at end of file