首页 > 其他 > 详细

thanks使用注意事项;

时间:2016-02-16 09:55:22      阅读:160      评论:0      收藏:0      [点我收藏+]
 1 router.get(‘/api/users/search/:key/:page‘, function(req, res) {
 2     if(_.isEmpty(req.params.key)) { res.json({items:null}); return; }
 3 
 4     var key = urlencode.decode(req.params.key);
 5     var page = parseInt(req.params.page);
 6     if(!page) page = 0;
 7     var query = {nickname: new RegExp(key, "i")};
 8     thunk.all([
 9       thunk(function(cb) { User.find(query).skip(page * 40).limit(40).exec(function(err, items) { cb(err, items); }); }),
10       thunk(function(cb) { User.count(query).exec(function (err, count) { cb(err, count); }); })
11     ])(function(cb, results) {
12       res.json({items: results[0], total:results[1]});
13     });
14   });

thunk.all()();

两个()连用,中间没有then;

thanks使用注意事项;

原文:http://www.cnblogs.com/suoking/p/5191781.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!