Create module to retrieve a list of genders by sport
parent
0d9e70896a
commit
c0ab9d4581
|
@ -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;
|
Reference in New Issue