Move gender constants into genders.js file in database directory

main
sudoer777 2021-11-21 16:30:36 -07:00
parent ff070acdf7
commit bdd943d422
3 changed files with 18 additions and 16 deletions

View File

@ -1,8 +0,0 @@
class Gender {
constructor(name) {
this.name = name;
}
}
exports.male = new Gender("male");
exports.female = new Gender("female");

View File

@ -1,5 +1,5 @@
const database = require('./../database');
const genders = require('../../constants/genders');
const genders = require('./genders');
@ -15,7 +15,7 @@ class Division {
function getGenderID(gender) {
return (gender == genders.male) ? "M" : "F";
return (gender == genders.MALE) ? "M" : "F";
}

View File

@ -1,10 +1,19 @@
const database = require('./../database');
const genders = require('../../constants/genders');
class Gender {
constructor(name) {
this.name = name;
}
}
const MALE = new Gender("male");
const FEMALE = new Gender("female");
async function retrieveBySport(sportID) {
const query = `SELECT gender
from scores.divisions
@ -17,16 +26,16 @@ async function retrieveBySport(sportID) {
return gendersList;
}
if(table.length == 2) {
gendersList.push(genders.female);
gendersList.push(genders.male);
gendersList.push(genders.FEMALE);
gendersList.push(genders.MALE);
return gendersList;
}
else if(table[0][0] = "F") {
gendersList.push(genders.female);
gendersList.push(genders.FEMALE);
return gendersList;
}
else if(table[0][0] = "M") {
gendersList.push(genders.male);
gendersList.push(genders.MALE);
return gendersList;
}
}
@ -34,5 +43,6 @@ async function retrieveBySport(sportID) {
exports.MALE = MALE;
exports.FEMALE = FEMALE;
exports.retrieveBySport = retrieveBySport;