Skip to content

Instantly share code, notes, and snippets.

@donwb
Created May 17, 2013 15:14
Show Gist options
  • Save donwb/5599727 to your computer and use it in GitHub Desktop.
Save donwb/5599727 to your computer and use it in GitHub Desktop.
exports.getGames = function getGames(start, end, callback) {
var s = start.format('YYYY-MM-DD');
var e = end.format('YYYY-MM-DD');
mongodb.connect(mongoUrl, function(err, con){
if(err) {
console.log('Error: ' + err);
}
con.collection('baseball', function(err, col){
col.find({"AirDate":{$gte: s, $lt:e}}).toArray(function(err, results){
_.each(results, function(result) {
req({url:result.awayUrl}, function(err, req, body) {
var data = eval('(' + body + ')');
console.log(body);
});
});
callback(results);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment