Add createSport function
parent
6f4a41fbd7
commit
64f4f9fb32
|
@ -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;
|
Reference in New Issue