javascript - Asynchronous Kitten Issue -



javascript - Asynchronous Kitten Issue -

i've been using mongoose query mongodb during web request like:

kittens.find() .where('born') .gt(startdate) .lt(enddate) .exec(function (err, kittens) { if (err) { // bad kitty } // fun kittens res.jsonp(kittendata); });

unfortunately, if have many kittens this happens

so need cut down amount of info pull back:

get real start date , real end date create temp start date , temp end date 1 days worth of kittens increment temp dates 1 until temp end date past real end date

the problem tried declare:

var allkittens = [];

and within loop query days worth of kittens:

allkittens.concat(todayskittens);

but allkittens tends still empty array.

i'm not javascript ninja, don't know how run async kitten query numerous times , concatenate kittens need single array can utilize when send response.

pwease help me

javascript node.js mongodb

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -