Add function to create teams
This commit is contained in:
parent
6e108ef975
commit
9c55999ad8
1 changed files with 22 additions and 0 deletions
22
database/scores/teams.js
Normal file
22
database/scores/teams.js
Normal 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);
|
||||
}
|
Reference in a new issue