From b533668445755edec9069951b212dcbe8870578b Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sat, 20 Nov 2021 21:52:32 -0700 Subject: [PATCH] Add function to create season --- database/scores/seasons.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 database/scores/seasons.js diff --git a/database/scores/seasons.js b/database/scores/seasons.js new file mode 100644 index 0000000..de32b2b --- /dev/null +++ b/database/scores/seasons.js @@ -0,0 +1,22 @@ +const database = require('./../database'); + + + + + +class Season { + constructor(id, year) { + this.id = id; + this.year = year; + } +} + + + +async function create(year) { + const query = `INSERT INTO scores.seasons(school_year) + VALUES($1) + RETURNING season_id;`; + const id = (await database.executeQuery(query, [year]))[0][0]; + return new Season(id, year); +} \ No newline at end of file