Created
July 12, 2014 20:11
-
-
Save myndzi/f5f148f1d549a51222be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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