Skip to content

Instantly share code, notes, and snippets.

@jgc128
Created September 6, 2013 18:57
Show Gist options
  • Save jgc128/6468347 to your computer and use it in GitHub Desktop.
Save jgc128/6468347 to your computer and use it in GitHub Desktop.
Mobile services | Top
function insert(item, user, request) {
var topTable = tables.getTable('Leaderboard');
var minItem = topTable.orderBy('Score').take(1).read({
success: function(results) {
if(item.Score > minItem.Score)
{
request.execute();
var newMinItem = topTable.orderBy('Score').take(1).read({
success: function(results) {
topTable.del(newMinItem);
}
});
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment