exports.getComments=function(query,skip,limit,callback){
Comment.find(query).sort({create_time:-1}).skip(skip).limit(limit).exec(function(error,comments){
if(error){
callback(error,null);
}
comments.foreach(function(index,comment){
Comment.find({reply_ID:comment.comment_ID}, function(err, replys){
comment.reply=replys;
});
});
callback(error,comments);
})
我的想法是将comment增加一个reply属性,然后再返回comments集合,但由于Comment.find是异步的,故向各位大虾求助,提供点解决方案的,初学,求照顾