From 9c55999ad88deea85a50cc6e0c38015a92efc43f Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sat, 20 Nov 2021 21:35:56 -0700 Subject: [PATCH] Add function to create teams --- database/scores/teams.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 database/scores/teams.js diff --git a/database/scores/teams.js b/database/scores/teams.js new file mode 100644 index 0000000..8d9858b --- /dev/null +++ b/database/scores/teams.js @@ -0,0 +1,22 @@ +const database = require('./../database'); + + + + + +class Team { + constructor(id, name) { + this.id = id; + this.name = name; + } +} + + + +async function create(name, sportID) { + query = `INSERT INTO scores.teams(team_name, sport_id) + VALUES($1, $2) + RETURNING team_id;`; + const id = (await database.executeQuery(query, [name, sportID]))[0][0]; + return new Team(id, name); +} \ No newline at end of file