Add function to create teams

main
sudoer777 2021-11-20 21:35:56 -07:00
parent 6e108ef975
commit 9c55999ad8
1 changed files with 22 additions and 0 deletions

View File

@ -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);
}