Skip to content

Instantly share code, notes, and snippets.

@BrianOstrander
Created March 9, 2015 23:03
Show Gist options
  • Save BrianOstrander/608a861a95292e0130d9 to your computer and use it in GitHub Desktop.
Save BrianOstrander/608a861a95292e0130d9 to your computer and use it in GitHub Desktop.
An excerpt of a NodeJS API for getting users between two ranks.
exports.getRanks = function(rankMin, rankMax, sinceUTC, callback) {
var sql = 'SELECT nickname,shared_identifier,items,experience FROM accounts WHERE ? < date_updated ORDER BY experience DESC LIMIT ?,?';
var sqlParams = [sinceUTC, rankMin, (rankMax - rankMin) + 1];
mysql.query(sql, sqlParams, function (err, result) {
if (err) {
console.log(err);
callback(err, null);
}
else {
callback(null, result);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment