YCPCS-481-TeamB / BaseballSim

CS481 Group Project
0 stars 0 forks source link

PlayersController Issue #26

Closed koopaluigi closed 7 years ago

koopaluigi commented 7 years ago

Going through the tests I wasn't sure which id this function was referring to, team_id or player_id. If it is referring to playerid, then it should be returning the player with resolve(data.rows[0]);_ instead of an array.

/**
 * Returns a promise that contains an array of the players with the requested id
 * @param id
 * @returns {Promise}
 */
exports.getPlayersById = function(id){
    return new Promise(function(resolve, reject){
        DatabaseController.query("SELECT * from players WHERE id = $1", [id]).then(function(data){
            resolve(data.rows);
        });
    });
}
bfwalton commented 7 years ago

Updated the Controller to only pull the player, added error checking to return an error when the player doesn't exist, and Comments to be more clear

Updated in Commit 5e7e8c4