Add createSport function

main
sudoer777 2021-11-20 16:53:13 -07:00
parent 6f4a41fbd7
commit 64f4f9fb32
1 changed files with 26 additions and 0 deletions

View File

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