tag_ctrl.get_all_tags(function(err,tags){
if(err) return next(err);
proxy.trigger('tags',tags); //触发事件
});
var opt = {skip:(page-1)*limit, limit:limit, sort:[['last_reply_at','desc']]};
topic_ctrl.get_topics_by_query({},opt,function(err,topics){
if(err) return next(err);
proxy.trigger('topics',topics);
});
opt = {limit:5, sort:[['visit_count','desc']]};
topic_ctrl.get_topics_by_query({},opt,function(err,hot_topics){
if(err) return next(err);
proxy.trigger('hot_topics',hot_topics);
});
opt = {limit:5};
user_ctrl.get_users_by_query({is_star:true},opt,function(err,users){
if(err) return next(err);
proxy.trigger('stars',users);
});
opt = {limit:10, sort:[['score','desc']]};
user_ctrl.get_users_by_query({},opt,function(err,tops){
if(err) return next(err);
proxy.trigger('tops',tops);
});
opt = {limit:5, sort:[['create_at','desc']]};
topic_ctrl.get_topics_by_query({reply_count:0},opt,function(err,no_reply_topics){
if(err) return next(err);
proxy.trigger('no_reply_topics',no_reply_topics);
});
topic_ctrl.get_count_by_query({},function(err,all_topics_count){
if(err) return next(err);
var pages = Math.ceil(all_topics_count/limit);
proxy.trigger('pages',pages);
});
请问这一些代码是干嘛用的?比如get_users_by_query这个函数,传了个{},是指传了一个空的参数集吧?然后回调里判断如果err,就执行下一次回调是吧?然后那个proxy.trigger('tops’,tops)这一句就猜不到是什么用处了。 还有请问一下在这边定义user_ctrl.get_users_by_query是为啥呢? 谢谢。