async function newHighscore(query){
    // Get info from query
    if (!query){ return; }
    let username = query.username;
    if (!username){ return; }
    let game = query.game;
    if (!game){ return; }
    let score = parseInt(query.score);
    if (!score){ return; }
    
    // Make sure user exists
    if (!await userExists(username)){
        await dbModel.addUser(username);
    }
    // User definitely exists

    // Get current score for user
    let currentScore = (await dbModel.getHighScore(username, game))[game];
    
    // If current score is better than new score do nothing
    if (currentScore > score){
        return;
    }

    // Add new highscore to database
    dbModel.setHighScore(username, game, score);
}
/*
 * Name: newHighscore
 * Description: Adds a new highscore to database
 * Return: None
*/
newHighscore
Description: Adds a new highscore to database
Return: None
newHighscore Description : Adds a new highscore to database Return : None
async function newHighscore(query){
    if (!query){ return; }
    let username = query.username;
    if (!username){ return; }
    let game = query.game;
    if (!game){ return; }
    let score = parseInt(query.score);
    if (!score){ return; }
    if (!await userExists(username)){
        await dbModel.addUser(username);
    }
    let currentScore = (await dbModel.getHighScore(username, game))[game];
    if (currentScore > score){
        return;
    }
    dbModel.setHighScore(username, game, score);
}
async function newHighscore ( query ) { if ( ! query ) { return ; } let username = query . username ; if ( ! username ) { return ; } let game = query . game ; if ( ! game ) { return ; } let score = parseInt ( query . score ) ; if ( ! score ) { return ; } if ( ! await userExists ( username ) ) { await dbModel . addUser ( username ) ; } let currentScore = ( await dbModel . getHighScore ( username , game ) ) [ game ] ; if ( currentScore > score ) { return ; } dbModel . setHighScore ( username , game , score ) ; }
Name: newHighscore
 Description: Adds a new highscore to database
 Return: None
Name : newHighscore Description : Adds a new highscore to database Return : None
// Get info from query // Make sure user exists // User definitely exists // Get current score for user // If current score is better than new score do nothing // Add new highscore to database