From c0ab9d45816ff0051a4ebdcaaa64e03d6ea19f77 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sun, 21 Nov 2021 15:52:54 -0700 Subject: [PATCH] Create module to retrieve a list of genders by sport --- database/scores/genders.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/scores/genders.js 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