Add function to create season
This commit is contained in:
parent
90e302c3ae
commit
b533668445
1 changed files with 22 additions and 0 deletions
22
database/scores/seasons.js
Normal file
22
database/scores/seasons.js
Normal file
|
@ -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);
|
||||
}
|
Reference in a new issue