diff --git a/database/scores/genders.js b/database/scores/genders.js new file mode 100644 index 0000000..857190f --- /dev/null +++ b/database/scores/genders.js @@ -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; \ No newline at end of file