Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created July 12, 2014 20:11
Show Gist options
  • Save myndzi/f5f148f1d549a51222be to your computer and use it in GitHub Desktop.
Save myndzi/f5f148f1d549a51222be to your computer and use it in GitHub Desktop.
CoinsVote.find( {} ,"name vote ip submitted" , function (err, data) {
if (err) {
console.error(err);
return;
}
if (data === null) {
console.log("No results");
return;
}
var votes = { };
data.forEach(function (vote) {
votes[vote.name] = (votes[vote.name] || 0) + vote.vote;
console.log("Adding " + vote.vote + " to " + vote.name);
});
console.log("Result:", votes);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment