码迷,mamicode.com
首页 > 其他好文 > 详细

thanks使用注意事项;

时间:2016-02-16 09:55:27      阅读:148      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!