Skip to content

Instantly share code, notes, and snippets.

@masylum
Created October 19, 2010 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masylum/634491 to your computer and use it in GitHub Desktop.
Save masylum/634491 to your computer and use it in GitHub Desktop.
Async with For Loop 2
var login_counts = [],
j = 30;
for (;j > 0;j--) {
tday.setDate(tday.getDate()+1);
yday.setDate(tday.getDate()+1);
// scope
(function (index, query) {
collection.find({date: query},function (err, cursor) {
cursor.count(function (err, count) {
login_counts[index] = count;
});
});
})(j, {'$gt':tday, '$lt':yday});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment