From 64f4f9fb32dcee891a822e6df9b2d5744016b5d7 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sat, 20 Nov 2021 16:53:13 -0700 Subject: [PATCH] Add createSport function --- database/scores/sports.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 database/scores/sports.js diff --git a/database/scores/sports.js b/database/scores/sports.js new file mode 100644 index 0000000..abdea6b --- /dev/null +++ b/database/scores/sports.js @@ -0,0 +1,26 @@ +const database = require('./database'); + + + +class Sport { + constructor(id) { + this.id = id; + } +} + +async function createSport(name) { + query = `INSERT INTO scores.sports(sport_name) + VALUES($1);`; + await database.executeQuery(query, [name]); + + query = `SELECT sport_id FROM scores.sports + WHERE sport_name = $1` + const sportId = await database.executeQuery(query, [name]); + console.log(sportId); + + return new Sport(sportId[0][0]); +} + + + +exports.createSport = createSport; \ No newline at end of file