Add function to create teams
parent
6e108ef975
commit
9c55999ad8
|
@ -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 New Issue