Create module to retrieve a list of genders by sport

main
sudoer777 2021-11-21 15:52:54 -07:00
parent 0d9e70896a
commit c0ab9d4581
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
const database = require('./../database');
const genders = require('../../constants/genders');
function getGendersBySport(sportID) {
const query = `SELECT gender
from scores.divisions
WHERE sport_id = $1;`;
const table = await database.executeQuery(query, [sportID]);
const gendersList = [];
if(table.length() == 2) {
gendersList.push(genders.female);
gendersList.push(genders.male);
}
else if(table[0][0] = "F") {
gendersList.push(genders.female);
}
else if(table[0][0] = "M") {
gendersList.push(genders.male);
}
return gendersList;
}
exports.getGendersBySport = getGendersBySport;