Create function to retrive seasons
parent
e9bda3c807
commit
c046eeb6ac
|
@ -27,4 +27,17 @@ async function remove(id) {
|
||||||
RETURNING school_year;`;
|
RETURNING school_year;`;
|
||||||
const year = (await database.executeQuery(query, [id]))[0][0];
|
const year = (await database.executeQuery(query, [id]))[0][0];
|
||||||
return new Season(id, year);
|
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;
|
||||||
}
|
}
|
Reference in New Issue